log4rs icon indicating copy to clipboard operation
log4rs copied to clipboard

Logging pattern does not depict logs as I declared it

Open EvilWatermelon opened this issue 1 year ago • 3 comments

I want that my log looks like this:

2024-05-02T10:45:28 [INFO] actix_server::server - Actix runtime found; starting in Actix runtime

But that does not work and looks like this:

2024-05-02T10:45:28.658835804+02:00 INFO actix_server::server - Actix runtime found; starting in Actix runtime

And I also want to use colors but that does not work either. What am I doing wrong?

appenders:
  stdout:
    kind: console
  requests:
    kind: threshhold
    encoder:
      kind: pattern
      pattern: "{h(%Y-%m-%d %H:%M:%S)} | {({l}):5.5} | [{f}:{L}] — {m}{n}"
      level_colors:
        INFO: Green
        WARN: Yellow
        ERROR: Red
        DEBUG: Orange
root:
  level: debug
  appenders:
    - stdout
loggers:
  app::requests:
    level: info
    appenders:
      - requests
    additive: true

EvilWatermelon avatar May 02 '24 08:05 EvilWatermelon

  1. Colors: We don't yet support modifying the highlight scheme. Here's an old PR that started the process: https://github.com/estk/log4rs/pull/224
  2. It looks like the only issue is related to the formatting of seconds? It looks like the crate we use to format time may have had some modifications. I'll take a look.

gauntl3t12 avatar May 16 '24 12:05 gauntl3t12

@EvilWatermelon I took a look and chrono has not changed their formatting. I ran some tests and believe "{h({d(%Y-%m-%d %H:%M:%S)} [{l:<5.5}] {M} - {m})}{n}" is the pattern you're looking for. I used the compile_time_config example to test it.

gauntl3t12 avatar May 17 '24 15:05 gauntl3t12

@EvilWatermelon Please close this if you're all set

gauntl3t12 avatar Jun 07 '24 15:06 gauntl3t12

closing for inactivity

estk avatar May 26 '25 07:05 estk