1

this is my log4j2.properties:

rootLogger.level = ALL customLevels = V customLevel.V.name = VERBOSE customLevel.V.intLevel = 525 property.filename = trace.log property.msgcolor = FATAL=BG_Yellow Red Bright, ERROR=Red, WARN=Yellow Bold, INFO=Green, DEBUG=BG_Magenta Yellow, TRACE=blue appenders = R, console appender.console.type = Console appender.console.name = STDOUT appender.console.layout.type = PatternLayout appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss,SSS} %highlight{%level}{${msgcolor}} %c{1}:%L]: %highlight{%msg}{${msgcolor}}%style{%n}{Default Normal}%throwable appender.R.type = RollingFile appender.R.name = File appender.R.fileName = ${filename} appender.R.filePattern = ${filename}.%d{yyyy-MM-dd} appender.R.layout.type = PatternLayout appender.R.layout.disableAnsi = true appender.R.layout.noConsoleNoAnsi = true appender.R.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{1}:%L - %m%n appender.R.policies.type = Policies appender.R.policies.size.type = SizeBasedTriggeringPolicy appender.R.policies.size.size = 20MB rootLogger.appenderRefs = R, console rootLogger.appenderRef.console.ref = STDOUT rootLogger.appenderRef.R.ref = File 

I expect that following code

customLevels = V customLevel.V.name = VERBOSE customLevel.V.intLevel = 525 

add a new custom level named VERBOSE and with intLevel value set to 525, but it doesn't take any effects. Why?

2
  • customLevels.V.name instead of customLevel.V.name perhaps? Commented Jan 11, 2018 at 0:13
  • @RAZ_Muh_Taz, No, I just tried. I think it should be as for appenders: appenders = APPENDER1, APPENDER2, ... | appender.APPENDER1.name = ... | etc... Commented Jan 11, 2018 at 0:22

2 Answers 2

2

Use below in ur log4j2.properties: customLevel.VERBOSE=525

Sign up to request clarification or add additional context in comments.

Comments

1

I faced similar issue, it works when we configure log4j2 properties using xml file and having issue when we have these properties in log4j2.properties file.

solution for now would be as below, where you mention custom level name directly and remove customerLevel.v.name property. This is until log4j2 fixes this issue.

simple solution: add below properties. for quick check, you can give the values as 1 instead for 525, 1 means it will log every time.

customLevels = VERBOSE customLevel.VERBOSE = 525

1 Comment

The currently supported syntax is customLevel.VERBOSE = 525. Also customLevels is ignored, all properties that start with customLevel. are registered.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.