Ignore:
Timestamp:
2006-10-17T15:52:42+13:00 (18 years ago)
Author:
shaoqun
Message:

added the code to use log4j and replace system.out or system.err to logger.info or logger.error respectively. The commented out output has been replaced with logger.debug. The log file is in web/logs/greenstone.log

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r10899 r13124  
    3232import java.util.ArrayList;
    3333
     34import org.apache.log4j.*;
     35
    3436/**
    3537 * GSFile - utility class for Greenstone.
     
    4446
    4547public class GSFile {
     48
     49     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GSFile.class.getName());
    4650
    4751    /**  site config file path */
     
    312316        data = readFile(in_filename);
    313317    } catch (Exception e) {
    314         System.err.println("GSFile.base64EncodeFromFile: couldn't read the file");
     318        logger.error("couldn't read the file");
    315319    }
    316320    String encodedString = Base64.encode(data);
     
    326330       
    327331    } catch (Exception e) {
    328         System.err.println("GSFile.base64DecodeToFile: file opening/closing errors"+e.getMessage());
     332        logger.error("file opening/closing errors"+e.getMessage());
    329333        return false;
    330334    }
     
    369373    public static boolean copyFile(File source, File destination) {
    370374    if (!source.isFile()) {
    371         System.err.println("GSFile.copyFile(): "+source.getPath()+" is not a file!");
     375        logger.error(source.getPath()+" is not a file!");
    372376        return false;
    373377    }
     
    383387        out.close();
    384388    } catch (Exception e) {
    385         System.err.println("GSFile.copyFile(): something went wrong copying "+source.getPath()+" to "+destination.getPath());
    386         System.err.println("Exception: "+e.getMessage());
     389        logger.error("something went wrong copying "+source.getPath()+" to "+destination.getPath());
     390        logger.error("Exception: "+e.getMessage());
    387391        return false;
    388392    }
     
    428432            input[i].delete();
    429433        } catch (Exception e) {
    430             System.err.println("GSFile.moveDirectory: exception: "+e.getMessage());
     434            logger.error("exception: "+e.getMessage());
    431435            return false;
    432436        }
Note: See TracChangeset for help on using the changeset viewer.