in reply to log4perl - accessing logger in subscripts/subroutines?

From my point of view you are mixing code and configuration file in a bad way when using references to source code inside the configuration file.
The logging inside the source code should be totally independent of the configuration of the logging - the only exception should be the location of the configuration file of the logging.
In an "industrial" environment it is normal, that the programmers write the perl code and admins change the configuration of the logging depending on the situation - e.g. increasing log levels only in case of problems, etc.
For the modules one should use a seperate logger for each module - I am usually using a local variable for each module and have an init log function which checks if the logger is initialised or not.
  • Comment on Re: log4perl - accessing logger in subscripts/subroutines?

Replies are listed 'Best First'.
Re^2: log4perl - accessing logger in subscripts/subroutines?
by ck2021 (Initiate) on Jan 19, 2009 at 18:12 UTC

    The source code reference inside the config file I actually took from an example in some Perl documentation and it seemed to fit well with my requirements.

    I am looking to use log4perl in a bit of a different way I think, in that I am not looking at setting up logging for a system. I want to track, record, email on error the results of each run of individual scripts. Our scripts are used to supplement and automate an in-house software package. Each main script is really standing alone as a separate function when it is run and I want to be able to access/distribute the ouput of that run separately from any other run.

    If you have any suggestions about a better way to implement this type of requirement, that would be great.

    Thanks Chris