beginners

Larry Jones 2025-08-07T23:05:01.055199Z

Google AI seems to indicate a number of ways to change the logging level. Some of the ways are from configuration files, and some require Clojure code early in the load process. It seems unclear that an obvious mechanism exists, since many of the solutions seem to look at the specific package used for logging for your application. -- To change the log level when starting a Clojure application that uses clojure.tools.logging, the approach depends on the underlying Java logging framework being used (e.g., Logback, Log4j, java.util.logging). 1. Configure the Logging Framework:Logback: If Logback is the underlying framework (often the default in many Clojure projects), the log level is typically configured in a logback.xml file located on the classpath. You can modify this file to set the desired log level for specific loggers or the root logger.


    
        
            
        
        
    
Log4j: For Log4j, a log4j.properties or log4j.xml file is used for configuration.
# Example log4j.properties snippet for setting root log level to DEBUG
    log4j.rootLogger=DEBUG, console
    log4j.appender.console=org.apache.log4j.ConsoleAppender
    log4j.appender.console.layout=org.apache.log4j.PatternLayout
    log4j.appender.console.layout.ConversionPattern=%-5p %c: %m%n
• java.util.logging (JUL): JUL uses a logging.properties file for configuration. 2. System Properties (Less Common for Initial Startup): While less common for setting the initial log level at startup, some frameworks allow setting log levels via system properties. For example, in Spring Boot applications, you can use logging.level.<logger-name>=<level> in application.properties. 3. Programmatic Configuration (Using Libraries like clj-logging-config): Libraries like clj-logging-config offer a Clojure-native way to configure logging programmatically, avoiding the need for XML or properties files. This can be integrated into your application’s startup code. Important Notes:Dependency on Logging Engine: Ensure you have a dependency on the chosen Java logging engine (e.g., ch.qos.logback/logback-classic, org.apache.logging.log4j/log4j-core) in your project.clj or deps.edn. • Classpath: The configuration file (e.g., logback.xml, log4j.properties) must be placed in a location accessible on the classpath when the Clojure application starts. • Log Levels: Common log levels include TRACE, DEBUG, INFO, WARN, ERROR, and FATAL, with TRACE being the most verbose and FATAL the least. AI responses may include mistakes.

2025-08-07T23:17:54.192349Z

you've copy pasted a bunch of AI generated nonsense without any clear question or goal. maybe start with a clear statement of your problem or goal if you need help

Larry Jones 2025-08-08T00:45:47.628949Z

Sorry, all, for the noise. I was trying to answer a previous, unanswered question. I failed.

gaverhae 2025-08-08T08:46:13.996069Z

I'm not too fond of AI responses on Slack myself; if I wanted an AI's opinion I would ask it directly. If I'm addressing a chatroom of what I expect to be people, it's because I want people answers. That being said, if you believe there is value in an AI's response to a specific question someone else has posted, it's a better approach to post that answer in the thread of that question, rather than in the channel itself.

gaverhae 2025-08-08T08:47:49.162199Z

If you want to use AI, it'd be a better approach to ask it privately, read its answer, test it, and then come back to Slack with a human-written summary of the findings, rather than copy/pasting the whole AI answer directly.

💯 2
➕ 4
penryu 2025-08-09T01:10:21.739509Z

Oh, this thread makes me feel better. For a minute I thought you had an AI bot in here.

Larry Jones 2025-08-07T23:05:48.842719Z

--

Doug Harvey 2025-08-07T03:05:52.445379Z

How do I change the log level for (say) starting clj. For example, I would like to see the debug output from io.pedestal.http.cors/allow-origin when I am experimenting with it in the REPL.

Bob B 2025-08-07T12:42:21.854129Z

there'll need to be a logging library on the classpath, and depending on which logger is in use, there will typically be multiple ways to change the log level (file-based config, JVM properties, sometimes environment variables)<https://pedestal.io/pedestal/0.7/reference/logging.html#_example_logback_test_xml> is an example that turns on debug

rolt 2025-08-08T06:01:29.562959Z

If you're using logback the https://github.com/pyr/unilog library is great for changing config at runtime

practicalli-johnny 2025-08-08T06:23:26.062279Z

https://practical.li/clojure-web-services/service-repl-workflow/mulog-events/ which has https://github.com/BrunoBonacci/mulog?tab=readme-ov-file#motivation. Its also much simpler to filter the log output when logging a structured event.