Question

I recently take over a web application project using websphere and log4j running under AIX. To create a development environment, I setup all the components in windows, using eclipse to compile a WAR file and deploy it.

All is working fine except that log file is not created. I changed the log file in log4j.properties from something like in below and and give everyone full access permission to the directory:

log4j.appender.F1.File=/abc/def/logs/admin.log

to

log4j.appender.F1.File=c:/logs/admin.log

What else can I check?

I create a simple standalone testapp which use the same log4j.properties and it can create the log file, but when the servlet deployed to websphere, it doesn't work. Please help! Thanks!

Was it helpful?

Solution

Ok, I think this article should help you. It seems that WebSphere CE uses log4j by default and controls it with a global properties file. There is a section on how to use application-specific properties files.

OTHER TIPS

Here is what I try and do to troubleshoot similar issues.

  1. Turn on log4j debugging to see where it actually picks up the file from. You need evidence of which file is picked up (so turning the debug on is a worthwhile activity) This provides you information with what log4j is trying to do to locate the configuration file.

    -Dlog4j.debug=true

  2. I would not hardcode the log4j location in the code. Instead I would use the log4j.configuration System property and state that in the JVM arguments. This way even I don't need to touch my code.

    -Dlog4j.configuration=file:///home/manglu/log4j.properties

I would use this approach irrespective of the runtime server that I use (be it Tomcat or WAS CE or WAS)

Hope this helps

I suggest you use environment variables set on your server like this :

You must access the admin console of your server. Under custom properties

Server_path=/abc/def/logs

In your log4j, use this : {$server_path}/log.txt

Make sure the user running the app has access to that directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top