2017-07-07 11 views
0

log4j.propertiesを持つmavenアプリケーションがあり、コンソールではなく指定したファイルにログを書き込むように設定しています。 Websphereサーバーの1つでEARを実行すると、期待どおりにファイルが作成され、ログが書き込まれます。しかし、他のwebsphereサーバーで同じEARを実行しているときは、指定されたファイルにログを書き込むのではなく、コンソールに書き込んでいます。私はパーミッションをチェックして、すべてがうまくいくようです。問題の内容を特定するのを手伝ってください。前もって感謝します。Log4jは1つのWebsphereサーバー上のファイルにログを書き込んでおらず、別のファイルにファイルを書き込んでいません

# CONSOLE APPENDER (stdout) 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
log4j.appender.stdout.Threshold=DEBUG 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
log4j.appender.stdout.layout.ConversionPattern=[%d] [%t] %-5p %20c - %m%n 

# ROLLING FILE APPENDER (on the file system) for memberpolicyattributesservice code 
log4j.appender.xxxxService=org.apache.log4j.RollingFileAppender 
log4j.appender.xxxxService.Threshold=DEBUG 
log4j.appender.xxxxService.File=/var/logs/xxxServer1/xxxServiceLog.log 
log4j.appender.xxxxService.layout=org.apache.log4j.PatternLayout 
log4j.appender.xxxxService.layout.ConversionPattern=%d{[email protected]:mm:ss} %-5p (%13F:%L) %3x - %m%n 
log4j.appender.xxxxService.MaxFileSize=10000KB 
log4j.appender.xxxxService.MaxBackupIndex=30 
log4j.appender.xxxxService.layout=org.apache.log4j.PatternLayout 
log4j.appender.xxxxService.layout.ConversionPattern=[%d] [%t] %-5p %20c - %m%n 



# ROLLING FILE APPENDER (on the file system) for hiberate, open source code log files 
log4j.appender.open_source_code=org.apache.log4j.RollingFileAppender 
log4j.appender.open_source_code.layout=org.apache.log4j.PatternLayout 
log4j.appender.open_source_code.Threshold=DEBUG 
#message format:YYYY-MM-DD HH:mm:ss,ms [ThreadId] <PRIORITY> classname.message 
log4j.appender.open_source_code.layout.ConversionPattern=%d [%t]<%-5p> %c.%m \r\n 
#file that will be logged to 
log4j.appender.open_source_code.File=/var/logs/xxxServer1/open_source_code.log 
log4j.appender.open_source_code.Append=true 
log4j.appender.open_source_code.MaxFileSize=1024KB 
log4j.appender.open_source_code.MaxBackupIndex=5 


#turn on log4j verbose mode 
log4j.debug = true 

# Set root logger level to INFO and its appender to DSInstrumentor,stdout. 
log4j.rootLogger=DEBUG,stdout,xxxxService 


# YOUR CATEGORIES (to customize logging per class/pkg/project/etc) 
log4j.category.fatal=FATAL,xxxxService 
log4j.category.error=ERROR,xxxxService 


#This will also enable the logging for all the children (packages and classes) of this package 

log4j.logger.com.xxxxx=ALL,xxxxService 

# Print only messages of level INFO in the open source code 
log4j.logger.org=INFO,open_source_code 

答えて

0

あなたのルートロガー(DEBUG、STDOUT、xxxxService)で定義された複数のロガーを持っていますが、それらはシステムの一つ上のファイルシステムにバインドされているようxxxxServiceロガーが見える:

log4j.appender .open_source_code.File =/var/logs/xxxServer1 /open_source_code.log

WASクラスター内の各サーバーでパスが有効であることを確認してください。

補足として、リモートサーバーでdebugとstdoutを使用しないでください。これは、ワークステーションのローカル開発では問題ありませんが、リモートボックスではありません。代わりに、さまざまな配備層に異なるlog4jプロパティを提供してください。これにより、ログの場所やアペンダー(デスクトップ上ではc:\ tempまたはCONSOLE、すべてのリモートマシン上では/ var/logs ...)とログレベル(デスクトップの場合はDEBUG、QAの場合はINFO、ステージング、WARNまたはERROR for Production)。

+0

返信いただきありがとうございます。私はルートロガーで複数のロガーを削除しようとしても、サーバー上で動作しないことがわかりました。ログレベルの提案をありがとうが、私はそのサーバー上で初めてアプリケーションをデプロイしようとしているので、ログレベルは「情報」ではなく「デバッグ」となっています。 –

+0

パスは両方のサーバーで同じですが、ログはサーバーのいずれかのコンソールに書き込まれていますが、他のサーバーでは正常に動作しています。サーバーレベルの設定を変更する必要があるかどうかはまだ分かりません。もしあなたが何かを知っているなら、私に知らせてください。 –

関連する問題