Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Default logging should write to stdout, not stderr #1144

Closed
batsatt opened this issue Nov 14, 2019 · 0 comments · Fixed by #1145
Closed

Default logging should write to stdout, not stderr #1144

batsatt opened this issue Nov 14, 2019 · 0 comments · Fixed by #1145
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@batsatt
Copy link
Contributor

batsatt commented Nov 14, 2019

java.util.logging.ConsoleHandler directs output to stderr, but server output would be better sent to stdout.

By fixing this with a new handler, we can also reduce the logging.properties boilerplate...

  1. Add a handler that writes to System.out and installs the WebServerLogFormatter formatter:
package io.helidon.common;

import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.StreamHandler;

public class HelidonConsoleHandler extends StreamHandler {

    public ConsoleHandler() {
        setOutputStream(System.out);
        setLevel(Level.ALL); // Handlers should not filter, loggers should
        setFormatter(new WebServerLogFormatter());
    }

    @Override
    public void publish(LogRecord record) {
        super.publish(record);
        flush();
    }

    @Override
    public void close() {
        flush();
    }
}
  1. Change all example logging.properties to use this handler and remove the explicit formatter, reducing the boilerplate (sans comments) to:
.level=INFO
handlers=io.helidon.common.HelidonConsoleHandler
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
@batsatt batsatt added the enhancement New feature or request label Nov 14, 2019
@batsatt batsatt self-assigned this Nov 14, 2019
@m0mus m0mus added this to the 1.4 milestone Nov 14, 2019
batsatt added a commit to batsatt/helidon that referenced this issue Nov 14, 2019
batsatt added a commit that referenced this issue Nov 18, 2019
* Changes default logging to write to System.out. Fixes #1144.

* Fixed copyrights.
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants