1
votes

I have an servlet which should log message with log4j. Under development environment (Windows + Eclipse + tomcat), the log4j is working.

When I deploy the servlet into production (AIX + websphere), it didn't give any log.

I don't know what happened. What is the possible reason? The war file was created by eclipse after verify the logging function was working in development environment. I want to gather more clues before I deploy it again in production.

The java program didn't give any clues. I looked up the SystemOut.log, and the log4j loggers were initialized successfully, however, they didn't say anything went wrong about the log files.

I suspect 2 reasons:

1) the logging directory have drwxr-xr-x privileges, may be the java program don't the right to create file there?

2) The log4j.properties files was strange. When I looked it up at AIX via vi, I discovered there was a ^M after every line ending. Probably unix don't need this carriage return character. Maybe this ^M character messed up the things?

EDIT: I found out there are another log file called SystemErr.log. It contained the error message:

[9/1/11 17:07:43:086 HKT] 00000013 SystemErr R log4j:ERROR setFile(null,true) call failed.

[9/1/11 17:07:43:086 HKT] 00000013 SystemErr R java.io.FileNotFoundException: /bps/log/BpsPdfBill.log (The file access pe rmissions do not allow the specified action.)

1

1 Answers

3
votes

How does it feel being a servlet? :-)

On topic: if you place your logfile outside of the folders where WAS unpacks your war file, who is the owner? To be able to write to the directory with those permision, the user was needs to be the owner (and has to have permission to access the parent folders too.)

The ^M characters are the newlines that are present in DOS/windows, for UNIX thay are whitespace and as such not a problem (just a nuisance) you can add a task in your Ant build file to remove the newlines before you pack the war archive.