Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Always log to console and file #7825

Merged
merged 11 commits into from
Sep 26, 2023
Merged

Conversation

hubertp
Copy link
Contributor

@hubertp hubertp commented Sep 18, 2023

Pull Request Description

The change adds an option by default to always log to a file with verbose log level.
The implementation is a bit tricky because in the most common use-case we have to always log in verbose mode to a socket and only later apply the desired log levels. Previously socket appender would respect the desired log level already before forwarding the log.

If by default we log to a file, verbose mode is simply ignored and does not override user settings.

Important Notes

To test run project-manager. That will output to the console with the default INFO level and TRACE log level for the file.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.

@hubertp hubertp marked this pull request as ready for review September 18, 2023 14:00
@hubertp hubertp force-pushed the wip/hubert/7752-verbose-file-output branch 2 times, most recently from 9adf63e to 5b0f20a Compare September 19, 2023 14:37
@hubertp
Copy link
Contributor Author

hubertp commented Sep 19, 2023

This PR now logs to console and log file with INFO and TRACE log levels, respectively, by default.

@hubertp hubertp changed the title Always log verbose to a file Always log verbose to console and file Sep 19, 2023
@hubertp hubertp changed the title Always log verbose to console and file Always log to console and file Sep 19, 2023
@hubertp hubertp added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Sep 21, 2023
@hubertp hubertp force-pushed the wip/hubert/7752-verbose-file-output branch from 5582b7f to a30c2e9 Compare September 22, 2023 12:39
@radeusgd
Copy link
Member

Can we measure what is the cost of always tracing?

i.e. on some example run in the CLI or on the startup time in the GUI (probably hard to measure)

I hope it is negligible but it would be nice to know the cost.

The change adds an option by default to always log to a file with
verbose log level.
The implementation is a bit tricky because in the most common use-case
we have to always log in verbose mode to a socket and only later apply
the desired log levels. Previously socket appender would respect the
desired log level already before forwarding the log.

If by default we log to a file, verbose mode is simply ignored and does
not override user settings.

To test run `project-manager` with `ENSO_LOGSERVER_APPENDER=console` env
variable. That will output to the console with the default `INFO` level
and `TRACE` log level for the file.
1. Log INFO level to CONSOLE by default
2. Change runner's default log level from ERROR to WARN

Took a while to figure out why the correct log level wasn't being passed
to the language server, therefore ignoring the (desired) verbose logs
from the log file.
Getting rid of the warning by adding a log4j over slf4j bridge:
```
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
```
Having `application.conf` in `src/main/resources` and `test/resources`
does not guarantee that in Tests we will pick up the latter. Instead, by
default it seems to do some kind of merge of different configurations,
which is far from desired.
Logging to console and (temporary) files is problematic for Windows.
The CI also revealed a problem with the native configuration because it
was not possible to modify the launcher via env variables as everything
was initialized during build time.
@hubertp hubertp force-pushed the wip/hubert/7752-verbose-file-output branch from bf8f4d1 to df40ac7 Compare September 25, 2023 19:58
@hubertp
Copy link
Contributor Author

hubertp commented Sep 26, 2023

Can we measure what is the cost of always tracing?

i.e. on some example run in the CLI or on the startup time in the GUI (probably hard to measure)

I hope it is negligible but it would be nice to know the cost.

The difference is negligible in both CLI and server mode, but I will be happy to get some feedback on Windows where it used to be the main pain point.

@hubertp hubertp merged commit 18b2491 into develop Sep 26, 2023
27 checks passed
@hubertp hubertp deleted the wip/hubert/7752-verbose-file-output branch September 26, 2023 09:32
hubertp added a commit that referenced this pull request Sep 28, 2023
PR #7825 enabled parallel logging to a file with a much more
fine-grained log level by default.
However, logging at `TRACE` level on Windows appears to be still
problematic.

This PR reduced the default log level to file from `DEBUG` to `TRACE`
and allows to control it via an environment variable if one wishes to
change the verbosity without making code changes.
hubertp added a commit that referenced this pull request Oct 2, 2023
* Enable log-to-file configuration

PR #7825 enabled parallel logging to a file with a much more
fine-grained log level by default.
However, logging at `TRACE` level on Windows appears to be still
problematic.

This PR reduced the default log level to file from `DEBUG` to `TRACE`
and allows to control it via an environment variable if one wishes to
change the verbosity without making code changes.

* PR comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants