Application cannot create log file in UNIX?

2019-08-22 09:43发布

问题:

I have developed a web project. Which is generating log file using log4j. But the same application is deployed in UNIX, it is not able to create log file also..
I'm new to unix. Why it is not creating log file? This is the code....

log4j.rootLogger = INFO,CA, FA

#Console Appender
log4j.appender.CA = org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout = org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern =  %d  %5p %c{1}:%L - %m%n

#File Appender
log4j.appender.FA = org.apache.log4j.FileAppender
log4j.appender.FA.File =correspondence.log
log4j.appender.FA.layout = org.apache.log4j.PatternLayout
log4j.appender.FA.layout.ConversionPattern = %d  %5p [%t] - %m%n

It is creating log file in server installation folder. But not creating in UNIX.. Any changes I have to do?

回答1:

try changing the line:

log4j.appender.FA.File =correspondence.log

to:

log4j.appender.FA.File = /tmp/correspondence.log

If it works, then create a log dir in the home directory of the user running the application server, chmod it at least to be executable and writable by owner and then put the log in that directory.