Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j log file names?

We have several jobs that run concurrently that have to use the same config info for log4j. They are all dumping the logs into one file using the same appender. Is there a way to have each job dynamically name its log file so they stay seperate?

Thanks
Tom

like image 491
DIA Tom Avatar asked Sep 17 '08 14:09

DIA Tom


People also ask

Where are log4j logs stored?

The Log4j logging settings are stored in the file app_data /conf/server/log4j. properties, where app_data is the application data folder. You can edit this file directly on the server or open it by clicking Settings > Logging.

What are log4j files?

Log4j is an open source project based on the work of many authors. It allows the developer to control which log statements are output with arbitrary granularity. It is fully configurable at runtime using external configuration files.

What is logger name in log4j XML?

In log4j a logger is associated with a package or sometimes with a particular class. Package/class of a logger is defined by the attribute "name". A logger logs messages in its package and also in all the child packages and their classes.


1 Answers

Can you pass a Java system property for each job? If so, you can parameterize like this:

java -Dmy_var=somevalue my.job.Classname

And then in your log4j.properties:

log4j.appender.A.File=${my_var}/A.log

You could populate the Java system property with a value from the host's environment (for example) that would uniquely identify the instance of the job.

like image 177
shadit Avatar answered Oct 16 '22 05:10

shadit