开发者

log4j not logging in AIX with websphere

开发者 https://www.devze.com 2023-04-01 18:35 出处:网络
I have an servlet which should log message with log4j. Under development environment (Windows + Eclipse + tomcat), the log4j is working.

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开发者_如何学Go 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.)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号