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

  1. the level from say INFO to I and ERROR to E
  2. record the time without the date
  3. 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

  1. the level from say INFO to I and ERROR to E
  2. record the time without the date
  3. 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 (1) 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
  • @life888888 which version of utilada does this work on? It doesn't change the log output on 2.6.0. – cup Commented Mar 4 at 11:56
  • Code for version 2.8.0 looks the same as code for version 2.6.0. It doesn't support ConversionPattern. – cup Commented Mar 5 at 12:05
Add a comment  | 

1 Answer 1

Reset to default 0

Having 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