문제

I have created a small program which logs text data to a file on some action. I am accessing the remote system where the program is deployed by Putty. I have run the program using nohup so that it keeps running even if i shut down my shell. Till the time i am logged into the shell it continues to log the data. However, as soon as i exit my shell it stops writing to the log file. My program still continues to run just that it doesn't write to the log file. I am using Java 1.6 + slf4j+log4j for logging. The OS is Ubuntu.

Would appreciate some help.

EDIT: my log4j.properties

log4j.rootLogger=DEBUG

log4j.appender.AdminFileAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.AdminFileAppender.File=pdmLogs.log
log4j.appender.AdminFileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.AdminFileAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} -- %p %t %c - %m%n

log4j.appender.ReportFileAppender=org.apache.log4j.ConsoleAppender
log4j.appender.ReportFileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ReportFileAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} -- %p %t %c - %m%n

log4j.logger.com.xxx.xxx.yyy=ReportFileAppender,AdminFileAppender
log4j.logger.com.xxx.xxx.zzz=ReportFileAppender,AdminFileAppender

The command which I am running is:

nohup java -cp jarfile.jar com.xxx.xxx.yyy.Main &
도움이 되었습니까?

해결책

Try changing your configuration to:

log4j.rootLogger=DEBUG, AdminFileAppender
...

다른 팁

How do you run the program? After running the program, do you see it among the list of process running by doing ps -ef | grep <process-id> Just to make sure, your program doesn't block at any time waiting for input? Also, check on the exit value of your process.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top