admin管理员组文章数量:1406937
The default format for Util.Log is
[date] level - module - : message
So something like
[2025-03-04 08:29:28] INFO - main - : Crypt : dc7e84bfda79164b7ecd8486985d3860
I'd like to change
- the level from say INFO to I and ERROR to E
- record the time without the date
- change the - to comma
So something like
08:29:28 I,main,Crypt : dc7e84bfda79164b7ecd8486985d3860
My configuration properties file is the default one I found in samples.
# Configuration for log4j
log4j.rootCategory=DEBUG,console,result,test
log4j.appender.result=File
log4j.appender.result.File=result.log
log4j.appender.test=syslog
log4j.appender.test.level=ERROR
log4j.appender.console=Console
log4j.appender.console.level=WARN
log4j.appender.console.layout=level-message
# Logger configuration
log4j.logger.log=DEBUG
log4j.logger.log.util=DEBUG
log4j.logger.Util.Properties=WARN
log4j.logger.Util=DEBUG
log4j.logger.Util.Log=WARN
I can't find a document that describes the layout or formatter for this configuration file. I've looked at Ada documents and Java documents. I've found documents that describe all the fields that are present but nothing about the formatter.
Is there a link to a document that describes how to set up the formatter?
The default format for Util.Log is
[date] level - module - : message
So something like
[2025-03-04 08:29:28] INFO - main - : Crypt : dc7e84bfda79164b7ecd8486985d3860
I'd like to change
- the level from say INFO to I and ERROR to E
- record the time without the date
- change the - to comma
So something like
08:29:28 I,main,Crypt : dc7e84bfda79164b7ecd8486985d3860
My configuration properties file is the default one I found in samples.
# Configuration for log4j
log4j.rootCategory=DEBUG,console,result,test
log4j.appender.result=File
log4j.appender.result.File=result.log
log4j.appender.test=syslog
log4j.appender.test.level=ERROR
log4j.appender.console=Console
log4j.appender.console.level=WARN
log4j.appender.console.layout=level-message
# Logger configuration
log4j.logger.log=DEBUG
log4j.logger.log.util=DEBUG
log4j.logger.Util.Properties=WARN
log4j.logger.Util=DEBUG
log4j.logger.Util.Log=WARN
I can't find a document that describes the layout or formatter for this configuration file. I've looked at Ada documents and Java documents. I've found documents that describe all the fields that are present but nothing about the formatter.
Is there a link to a document that describes how to set up the formatter?
Share Improve this question edited Mar 4 at 9:33 Joop Eggen 110k8 gold badges87 silver badges140 bronze badges asked Mar 4 at 9:26 cupcup 8,3214 gold badges22 silver badges44 bronze badges 3 |1 Answer
Reset to default 0Having had a look at utilada_2.6.0../src/base/log/util-log-appenders.adb, it looks like the formats are fixed. The layout is in the following line.
log4j.appender.console.layout=<layout>
where <layout> can be
- message
- level-message (level: message)
- date-level-message ([date time] level: message)
- level-date-message ([date time] level: message)
- if not one of the above then the layout is set to FULL ([date time] level - logger - message)
Looks like if I wish to change to log format, I will have to override some of the functions in util-log-appenders.
Edit
The code is the same on utilada 2.8.0.
本文标签: log4jHow to change output format in Ada loggingStack Overflow
版权声明:本文标题:log4j - How to change output format in Ada logging - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745052709a2639749.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
log4j.appender.console.layout.ConversionPattern=%-1p %c{1}:%L,%m%n
(2)log4j.appender.result.layout.ConversionPattern=%-1p %c{1}:%L,%m%n
(3)log4j.appender.test.layout.ConversionPattern=%-1p %c{1}:%L,%m%n
– life888888 Commented Mar 4 at 9:48