I just added some code to my org.apache.turbine.util.Log.java that would
give the ability to use multiple logs in turbine. If this doesnt cause
any unforseen conflicts, problems etc. can this be added into the code? 
Here is the code:
###############################################
>
>     /*
>      * Points the logfile to the file specified in the TurbineResources.properties
>      * file at the passed in parameter.  So if the TurbineResources.properties
>      * file has:
>      *      dblogfile=/turbine/logs/turbinedb.log
>      *
>      * the call Log.setLogFile("dblogfile") and the Log.note("testing 1 2 3")
>      *
>      */
>     public static void setLogFile(String logFilePropertyName)
>     {
>       try
>               {
>                 String logFileString = 
>TurbineResources.getString(logFilePropertyName, null);
>                 if (logFileString == null)
>                 {
>                     throw new Exception (
>                 "The " + logFilePropertyName + "= property in the 
>TurbineResources.properties file is null or could not be found.\n" +
>                 "Please make sure that you have properly defined the path to the 
>TurbineResources.properties file\n" +
>                 "and you have called 
>\"TurbineResourceService.setPropertiesFileName(\"/path/to/TurbineResources.properties\");\"
> in yourcode.\n" +
>                 "If you are using this class with the Turbine Servlet, this should 
>have been called for you already.\n" +
>                 "If you are getting this error using the Turbine Servlet, the path 
>to the properties file or\n" +
>                 "the path to the logfile was not defined correctly. Please refer to 
>the INSTALL \n" +
>                 "document for instructions on how to do this.\n");
>                 }
>                 logfile = new FileWriter( logFileString, true );
>               }
>             catch (Exception e)
>             {
>                 e.printStackTrace();
>                 isValid = false;
>             }
>               catch (Throwable t)
>               {
>                 isValid = false;
>               }
>     }
>
###############################################

This allows me to have multiple logs setup in th
TurbineResources.properties like so:

seclogfile=/turbine/logs/turbine-security.log
dblogfile=/turbine/logs/turbinedb.log 

I can then do:

Log.setLogFile("dblogfile");
Log.note("insert record into db");

Log.setLogFile("seclogfile");
Log.note("user A has logged in");


I tested it and it seems to work OK.

Thanks,
John

-- 
********************************
** John Thorhauer
** Web Developer
** Phoenix Color Corp.
** [EMAIL PROTECTED]
********************************


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to