Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

how to do log4j properties file as a common file for all modules in java

Hi Experts,
I have 10 modules in my project.
Each module having separate log4j properties file
log4j properties file name along with path configured context params of web.xml file

Log level:
info ,debug,trace

any specific module i want to see all the logs i can change log level to trace
log4j.rootLogger=TRACE, stdout, file
then i can able to see all the logs.

instead of creating 10 or 15 log4j properties file names
i want to make a common log4j.properties file
then i want to see all the logs
is it possible?
if it is possible i have a problem here
now i want to see a specific module log level upto trace
trace will print all the logs like info,debug,trace if it prints all the logs
and my log file size going upto max size level immediately.

here i need a solutiion like from the common log4j properties file
for specific if i want to print trace i have get trace level logs only for specific module
rest of the modules has to show info level.

some one can suggest me how to do
Thanks,
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

theres no reason why you cannot have a single log4j file.
If all the modules are deployed together, the log4j file just needs to be on the classpath.


And then in the log4j.properties file put something like
log4j.logger.com.myproject.mymodule1=trace

where com.myproject.mymodule1 is the package for a particular module.
Avatar of CEHJ
I have 10 modules in my project.

Java doesn't (yet) support 'modules'. What do you mean by that?
intellij modules perhaps.
Avatar of srikotesh
srikotesh

ASKER

hi gurpbassi,

how to can i provide project name ?
module name means i can add war name as module name.
some where i have to configure these module name and project name right.

hi cehj,
Consider i have 10 wars in my tomcat webapps.
SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What is your motivation?
Hi CEHJ,

I Want to see all the logs in single log file.
I Want to restrict the log level whenever i want, i mean to see info or debug or trace.

Hi gurpsbassi,
I am using Tomcat server in which file we can see the log restriction.
logging.properties file is the one to modify the log levels?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I Want to see all the logs in single log file.
That could easily be achieved with a shell script, without interleaving everything.
yes gurpsbassi you are correct making all applications into single log file will be difficult for trouble shooting.
Hi Cehj,

can you explain how to achieve single log file thru shell script.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial