logginglog4jada

How to change output format in Ada logging


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?


Solution

  • 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

    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.