I just got asked by a colleague why do I use different levels of a logger. He said he's been writing code for 10+ years and never needed anything other than Logger.debug() 🤦‍♂️

Where the fuck these guys get their degrees? 😒

  • 2
    I also use mostly one level debug.
    I prefer different files then different levels. It’s easier to open and follow 100mb file then 1gb file on server if something got wrong.
  • 0
    Forgot to mention I got named each logger in each file differently if that’s what level is I got gazilion of it.
  • 8
    Here are the log entry types/levels I use:

  • 5
    You mean to get a degree we must use all kinds of debug levels? Which rule on earth states so?
    Use what you need to, not everything.
  • 4
    so why do you use logger at all? Why not just print it all ro stdout/stderr? You kind of beat the very core purpose of logger.

    @leduyquang753 yes, one should know tools have their purpose.
    If you only need to drive to work, purchasing a tank might be a slight overkill.
    If you just need some messages printed out, using logger might be a slight overkill.
  • 0
    @leduyquang753 Mate, what and how you use log levels is part of my rant.

    The degree comment was more along the lines of "you should at least know what other levels are" if you have a degree in IT. If you left uni without learning that you should ask them for a refund.

    My colleague actually though that logger. debug() is only for Debug builds and that it's "removed" from Release builds, so he thought it's safe to log passwords and keys 😒
  • 3
    @LordPeeve I see your coleague is begging for a nice kick in the nuts.
  • 1
    @Root Wow, now even I'm ashamed 😂

    Genuinely curious, what do you log at Meta level? I always felt there's room for more levels in standard slf4j 🤔
  • 1
    @LordPeeve 😊 Thanks!
    I'm writing a nested logging library that implements these types (plus a bunch of other features) in my total lack of free time. I may post a link here when it's ready for release, but I don't want to tie my devRant identity to my real one, so I might not.

    But to answer your question:
    "Meta" is for log entries from/about the logger itself. Changes in log-level, delayed file writes, disk/access errors, etc. Useful when the log output also goes to stdout/err.
  • 0
    @Root Got ya 👍

    Why i/o errors on meta, I've been logging warn/error so far.

    I always felt there should be a Profile level to log performances outputs.
  • 1
    @LordPeeve Only logging-specific I/O errors. The logger itself writes these entries to the log. The application using the logger doesn't use the meta type, and in fact won't have access to it.

    For profiling data, I feel that would best have its own log file.
  • 1
    @Root Wise words 😊

    Love it when rant turns into a valuable lesson. Thanks 🙏
  • 1
  • 0
    @Root I need to ask this:

    How is it possible to log by FATAL ? I thought ERROR was the worst. Do you mean the FATAL-log as introduction to a Core-dump?

    What is FATAL? Lost Threads? Inconistent Database?
  • 3
    @leduyquang753 For toys project yes, do whatever you want.

    For serious project, this is the minimum:

    - Debug: Use for non-errors that can be turned off in production.
    - Info: Use for non-errors, this should be leave on in production.
    - Warn: Use for errors that can be safely ignored.
    - Error: Use for errors that must NOT be ignored.
    - FATAL: Use when the application crash.


    1. You can set monitoring (count the INFOs and WARNs) to measure the traffic, success and failure rate.

    2. You can set alerts (count the Errors and Fatal), let the system notify you directly on the phone as soon as a problem occurs.

    3. You can turn on debugging and turn them off when no longer needed.
  • 2
    @Kruzifix Fatal is for anything that the program cannot recover from, or that prevents it from working and forces a crash/termination. (It's not possible to log all fatal errors, of course.)

    Failed autoupdate that kills the install (literal fatal error!), corrupt database, internal inconsistencies, runtime exceptions, missing files, etc.
  • 1
    @nam17887 Love the Why section mate 👍
  • 1
    @netikras I use it cause it provides me functionality to save to file, split files based on logger instance and report errors as ERROR level.

    I log to many files cause I have many systems I need to communicate with and some requests I want to backup for further processing.

    My structure gives me instant access to issues, isn’t it purpose of logging?
  • 2
    @vane so you DO use other levels than just DEBUG :)
  • 0
    @netikras yeah that’s so obvious I forgot about it
  • 0
    @LordPeeve Your rant didn't say "he knows nothing other than DEBUG" but rather "he only needs DEBUG".
    @nam17887 I didn't say you should know only what you need - learning new stuff has never been not interesting. The log levels, as weel as everything else, people may know about, but some people will need to use them, others simply don't, and you have no reason to accuse them for not using unless required.
  • 1
    Logging takes I/O and costs performance and on top makes logs more useful but harder to read. The whole point of levels (at least in my opinion atleast) is to be able to switch them around when something is wrong.. production needs to still log errors and warnings, but doesnt need debugging help. But a developer will be happy to see those, so instead of deleting them when you dont need them, you keep them in and just turn them off for production. And then theres commonly also TRACE which should be the most hardcore log that takes you almost step by step through important functions and subfunctions. Thats for when the debug log just seems all fine but something is wrong and you cant track it (perhaps you dont have access to the source code and a debugger but need to track a bug down)... Thats how I use them
Your Job Suck?
Get a Better Job
Add Comment