私は、親クラスからほとんどのメソッドと属性を継承するクラスの内部でlog4jオブジェクトをインスタンス化しています。今は、サブクラスからのメッセージのみをロギングしています。スーパークラスとサブクラスの両方でログメッセージを出力するにはどうすればよいですか?継承クラスでlog4jを使用する
public class SuperClass {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(SuperClass.class);
/* Rest of code goes here */
} // end SuperClass
クラスとサブクラスのために同じ:
EDIT:それは次のようになりますので、私はロギングを行う午前方法は、私はサブクラスとスーパークラスの両方でインスタンス変数を持っているということです。
私のlog4jの設定:
## gps log4j.rootLogger==ERROR, clientLog, catissuecoreclientLog
log4j.rootLogger==DEBUG, clientLog, catissuecoreclientLog
### direct messages to file hibernate.log ###
log4j.appender.clientLog=org.apache.log4j.FileAppender
log4j.appender.clientLog.File=./log/client.log
log4j.appender.clientLog.layout=org.apache.log4j.PatternLayout
log4j.appender.clientLog.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.catissuecoreclientLog=org.apache.log4j.FileAppender
log4j.appender.catissuecoreclientLog.File=./log/catissuecoreclient.log
log4j.appender.catissuecoreclientLog.layout=org.apache.log4j.PatternLayout
log4j.appender.catissuecoreclientLog.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1} - %m%n
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
#log4j.rootLogger=warn, stdout
#log4j.rootLogger=warn, file
#log4j.logger.org.hibernate=info
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
"log4jオブジェクト"とは何ですか? – skaffman
上記のコードサンプルにあるloggerインスタンス変数。 – Brian
私は 'log4j.rootLogger == DEBUG'の二重等号を入力しますか?また、stdoutアペンダーがlog4j.rootLoggerで指定されていない – ChssPly76