[
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17508008#comment-17508008
]
Ragini Gawande commented on LOG4J2-3419:
----------------------------------------
[~pkarwasz]
I have attached the custom Level.java class which has {{public static Level
toLevel(String, Level)}} method.
I have also attached the log4j.properties file which we are using
In this file if we keep rootlogger as
log4j.rootLogger=FINEST#{*}org.apache.log4j.helpers.UtilLoggingLevel{*},
TRACE_LOGGER, stdout, SYSLOG
then the output we get is as followed, here it prints all logs for FINEST level
and above but the custom level are printed as ERROR
2022-03-16 16:45:05,836 Main[OFFid] :main: example.com.Test OFF - Ragini
Level.OFF log
2022-03-16 16:45:05,839 Main[FATALid] :main: example.com.Test FATAL - Ragini
Level.FATAL log
2022-03-16 16:45:05,840 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.ERROR log
2022-03-16 16:45:05,840 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.WARNING log
2022-03-16 16:45:05,841 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.SEVERE log
2022-03-16 16:45:05,841 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.UM_INFO log
2022-03-16 16:45:05,841 Main[INFOid] :main: example.com.Test INFO - Ragini
Level.INFO log
2022-03-16 16:45:05,842 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.CONFIG log
2022-03-16 16:45:05,843 Main[ERRORid] :main: example.com.Test ERROR - Ragini
Level.FINE log
And if we keep rootlogger as
log4j.rootLogger=FINEST#com.test.common.logging.Level, TRACE_LOGGER, stdout,
SYSLOG
it considers FINEST as debug by default and prints all logs for DEBUG level and
above and the custom level are still printed as ERROR
2022-03-17 12:07:55,037 DmccMain[OFFid] :main: example.com.Test OFF - Ragini
Level.OFF log
2022-03-17 12:07:55,040 DmccMain[FATALid] :main: example.com.Test FATAL -
Ragini Level.FATAL log
2022-03-17 12:07:55,040 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.ERROR log
2022-03-17 12:07:55,040 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.WARNING log
2022-03-17 12:07:55,041 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.SEVERE log
2022-03-17 12:07:55,041 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.UM_INFO log
2022-03-17 12:07:55,041 DmccMain[INFOid] :main: example.com.Test INFO - Ragini
Level.INFO log
2022-03-17 12:07:55,041 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.CONFIG log
2022-03-17 12:07:55,041 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.FINE log
2022-03-17 12:07:55,042 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.FINER log
2022-03-17 12:07:55,042 DmccMain[ERRORid] :main: example.com.Test ERROR -
Ragini Level.FINEST log
2022-03-17 12:07:55,042 DmccMain[DEBUGid] :main: example.com.Test DEBUG -
Ragini Level.DEBUG log
> Unable to create custom logging level using log4j 2 Bridge API
> --------------------------------------------------------------
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
> Issue Type: Bug
> Components: Log4j 1.2 bridge
> Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
> Reporter: Ragini Gawande
> Assignee: Piotr Karwasz
> Priority: Blocker
> Fix For: 2.17.3
>
> Attachments: DemoCustom.zip, Level.java, log4j.properties
>
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);*
>
> Using FINE logging level is considered to be DEBUG level by default while
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT:
> Level.FINE log
>
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT:
> Level.FINE log
--
This message was sent by Atlassian Jira
(v8.20.1#820001)