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 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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 file put something like

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

Java doesn't (yet) support 'modules'. What do you mean by that?
intellij modules perhaps.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

srikoteshAuthor Commented:
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.
If they are 10 different wars i.e 10 different projects then I would configure the logging at the application server and not try to bundle in your deployables.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
some where i have to configure these module name and project name right.

What gurpsbassi was talking about with, that "myproject" and "mymodule" are just components of the package name. So the example he gave is assuming all the code for one of the modules has the Java package name "com.myproject.mymodule1" (or some sub-package of that) and that the code in the other modules have different package names.

You do have a good package name hierarchy, don't you? One that would make it easy to differentiate the code in the different modules?
What is your motivation?
srikoteshAuthor Commented:

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. file is the one to modify the log levels?
I Want to see all the logs in single log file.

Do you really think that is wise?

You are going to end up with a big log file with logging from a mixture of apps, with log statements interleaving.
It will end up being a nightmare to try and troubleshoot the application.
I Want to see all the logs in single log file.
That could easily be achieved with a shell script, without interleaving everything.
srikoteshAuthor Commented:
yes gurpsbassi you are correct making all applications into single log file will be difficult for trouble shooting.
srikoteshAuthor Commented:
Hi Cehj,

can you explain how to achieve single log file thru shell script.
find $ROOT -type f -name log4j.log -exec cat '{}' >>$OUTPUT_FILE \;

Open in new window

should do it

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.