Nipun
Nipun

Reputation: 2261

java.lang.IllegalArgumentException from log4j

My client is facing a problem and he has sent me log file.
Log file contain few crashes as written below.

log4j:WARN Failed to set property [maxFileSize] to value "10MB". 
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

log4j:WARN Failed to set property [file] to value "../logging/serviceContainer2100.log". 
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

log4j:WARN Failed to set property [maxBackupIndex] to value "10 ". 
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

Enclosed is log4J configuration file:

# Set root logger level and appenders.
log4j.rootLogger=info, A1, R

# Appender A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# Layout for A1
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

# Appender R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=log/DependencyAnalyzer.log
log4j.appender.R.MaxFileSize=1000KB
log4j.appender.R.MaxBackupIndex=10

# Layout for R
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

I tried googling about this but couldn't get any satisfactory response.
Can anyone suggest where to look to dig more in to this problem or what could be possible reason?

Upvotes: 1

Views: 2049

Answers (1)

bmscomp
bmscomp

Reputation: 777

Seems there is a wrong value of file attribute ../logging/serviceContainer2100.log comparing the value that is in your configuration file, Please would you try this log4j.properties configuration file , thant may give you some help , I just made some changes on the path of file and some appenders for test but it worked for me , waiting your feedback

# Root logger option
log4j.rootLogger=DEBUG,A1 , A,  R


 # Appender A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# Layout for A1
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n


# Redirect log messages to console
log4j.appender.A=org.apache.log4j.ConsoleAppender
log4j.appender.A.Target=System.out
log4j.appender.A.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.A.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


# Redirect log messages to a log file, support file rolling.
#log4j.appender.file=org.apache.log4j.RollingFileAppender
#log4j.appender.file.File=file.log
#log4j.appender.file.MaxFileSize=5MB
#log4j.appender.file.MaxBackupIndex=10
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


# Appender R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=trace.log
log4j.appender.R.MaxFileSize=1000KB
log4j.appender.R.MaxBackupIndex=10

# Layout for R
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

Upvotes: 1

Related Questions