Re: [D] How do I register a StatusListener in configuration? [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user ppkarwasz added a comment to the discussion: How do I register a 
StatusListener in configuration?

We could probably register status listeners automatically using 
`ServiceLoader`, which is in practice the only way to ensure that they are 
registered **before** `StatusLogger` is used for the first time. The behavior 
could be similar to a JUnit 
[`LauncherSessionListener`](https://junit.org/junit5/docs/current/user-guide/#launcher-api-launcher-session-listeners-custom).

Of course for security reasons, there should also be a configuration property 
to turn on the auto-registration. Personally, I am open to a PR in this 
direction.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3576#discussioncomment-12644421


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] How do I register a StatusListener in configuration? [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user vy added a comment to the discussion: How do I register a 
StatusListener in configuration?

This is explained in [the Status Logger 
documentation](https://logging.apache.org/log4j/2.x/manual/status-logger.html#listeners).
 You need to programmatically do it.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3576#discussioncomment-12638488


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] How do I register a StatusListener in configuration? [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user vy edited a comment on the discussion: How do I register a 
StatusListener in configuration?

This is explained in [the Status Logger 
documentation](https://logging.apache.org/log4j/2.x/manual/status-logger.html#listeners).
 You need to programmatically do it. This is also stated in the JavaDoc you 
linked:

> You can programmatically register listeners using 
> `registerListener(StatusListener)`

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3576#discussioncomment-12638488


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] Provide a Layout to StatusLogger [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user ppkarwasz added a comment to the discussion: Provide a Layout to 
StatusLogger

> The error messages are somewhat useful to me as a user, but stack traces from 
> inside of log4j are only useful for maintainers of the log4j library.

There are [options for the date format of status 
logger](https://logging.apache.org/log4j/2.x/manual/status-logger.html#log4j2.statusLoggerDateFormat),
 so I wouldn't be against an option that disables stack traces. Feel free to 
submit a PR.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3578#discussioncomment-12644341


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] Provide a Layout to StatusLogger [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user voddan added a comment to the discussion: Provide a Layout to 
StatusLogger

I see. That kinda makes sense, however I wish there was a way to at least turn 
of the stack traces. The error messages are somewhat useful to me as a user, 
but stack traces from inside of log4j are only useful for maintainers of the 
log4j library.


> avoiding passing the same exception to the status logger in subsequent calls

Not applicable to me since my code is not using the status logger directly.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3578#discussioncomment-12639808


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] How do I register a StatusListener in configuration? [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user voddan added a comment to the discussion: How do I register a 
StatusListener in configuration?

@vy How would it look in a project? If you can share an example project where 
you do it like that, it would be great.

Simply put, I don't understand where I should put this line of code 
`statusLogger.registerListener(StatusListener)`, considering that I can't put 
it into the code of the app.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3576#discussioncomment-12639233


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] Provide a Layout to StatusLogger [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user vy added a comment to the discussion: Provide a Layout to 
StatusLogger

No, it is not possible and, IMHO, this is a good thing. Status Logger is the 
logger for the logger – that is, we need to keep its feature set at minimum. 
Consider it like a `printf()` on steroids.

> When I get networking problems with my appender, it prints elaborate error 
> messages with extensive stack traces

If this is an unexpected failure, it is good to point to the user the origin by 
means of a stack trace. If this is something regular, you might consider either 
introducing a rate limiter to the error messages you emit, or avoiding passing 
the same exception to the status logger in subsequent calls.

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3578#discussioncomment-12638574


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org



Re: [D] How do I register a StatusListener in configuration? [logging-log4j2]

2025-03-27 Thread via GitHub


GitHub user vy added a comment to the discussion: How do I register a 
StatusListener in configuration?

```
StatusLogger.getLogger().registerListener(...)
```

You need to place this snippet as early as possible in your application 
initialization, e.g.,

```
static {
StatusLogger.getLogger().registerListener(...)
}

public static void main(String[] args) { ... }
```

GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3576#discussioncomment-12639529


This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org