Serdar Gökay created CAMEL-26924:
------------------------------------

             Summary: camel-jbang - camel run --logging-json writes no log 
file, so camel log shows nothing
                 Key: CAMEL-26924
                 URL: https://issues.apache.org/jira/browse/CAMEL-26924
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
    Affects Versions: 4.23.0
            Reporter: Serdar Gökay
             Fix For: 4.24.0


With JSON logging (the logging-json option of camel run) the console is ECS 
JSON and nothing is written to {{<pid>.log}} in the Camel directory of the CLI. 
{{log4j2-json.properties}} has the console appender only; 
{{log4j2-color.properties}}, {{log4j2-no-color.properties}} and 
{{log4j2-off.properties}} have the file appender too. That file is what {{camel 
log}}, the TUI (log tab, timeline) and the AI tools ({{camel_get_log}}, the 
reload checks) read.

To reproduce, on main at 9235b3ca29f (4.23.0 has the same JSON configuration):

{noformat}
camel run hello.camel.yaml --logging-json
camel log --follow=false
{noformat}

{{camel log}} prints nothing. {{<pid>.log}} is there with 0 bytes, and after 
the run {{<name>-previous.log}} is kept empty.

With a logging category there is a second effect: the logger of the category 
refers to the file appender, which the JSON configuration does not have.

{noformat}
camel run hello.camel.yaml --logging-json 
--logging-category=org.apache.camel.impl=DEBUG
main ERROR Unable to locate appender "file" for logger config 
"org.apache.camel.impl"
{noformat}

The JSON configuration is from 2022 (the commit under CAMEL-18067), before 
camel run logged to a file (CAMEL-18538), and it was not given the file 
appender then. The configuration without color was in the same state until 
https://github.com/apache/camel/pull/22337 added the appender.

Proposed change: {{log4j2-json.properties}} gets the file appender of 
{{log4j2-no-color.properties}}. The JSON stays on the console, where the log 
collector of a container reads it. The file keeps the pattern, so camel log, 
the TUI and the AI tools read it as they do today. I have a PR for it.

_Claude Code on behalf of etzel-mes_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to