<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Logger on Micha Kops&#39; Tech Notes</title>
    <link>https://www.hascode.com/tags/logger/</link>
    <description>Recent content in Logger on Micha Kops&#39; Tech Notes</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2010 - 2025 Micha Kops. #e9d956c0c0154a221ad83c925346a8fa0e72f866</copyright>
    <lastBuildDate>Thu, 19 Aug 2021 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://www.hascode.com/tags/logger/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Logback and Spring Boot - Change Log Level to custom format</title>
      <link>https://www.hascode.com/logback-and-spring-boot-change-log-level-to-custom-format/</link>
      <pubDate>Thu, 19 Aug 2021 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/logback-and-spring-boot-change-log-level-to-custom-format/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_create_a_custom_converter&#34;&gt;Create a custom converter&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;This class converts the well known log levels to a custom format&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;title&#34;&gt;CustomLogLevelConverter.java&lt;/div&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;package com.hascode;

public class CustomLogLevelConverter extends ClassicConverter {
    @Override
    public String convert(ILoggingEvent event) {
        switch (event.getLevel().toInt()) {
            case Level.ERROR_INT:
                return &amp;#34;ERROR!!!&amp;#34;;
            case Level.WARN_INT:
                return &amp;#34;WARN!!&amp;#34;;
            case Level.INFO_INT:
                return &amp;#34;INFO!&amp;#34;;
            case Level.TRACE_INT:
                return &amp;#34;DEBUG&amp;#34;;
            default:
                return event.getLevel().toString();
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_register_the_converter&#34;&gt;Register the converter&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;The following Logback config includes some defaults and registers our custom converter.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Eclipse Snippets</title>
      <link>https://www.hascode.com/eclipse-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/eclipse-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_favorites&#34;&gt;Favorites&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Spare my time when using static imports ..&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;code&gt;Window &amp;gt; Preferences &amp;gt; Java &amp;gt; Editor &amp;gt; Content  Assist &amp;gt; Favorites&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code&gt;com.google.common.collect.Lists
com.jayway.restassured.matcher.RestAssuredMatchers
com.jayway.restassured.RestAssured
io.restassured.matcher.RestAssuredMatchers
io.restassured.RestAssured
org.hamcrest.MatcherAssert
org.hamcrest.Matchers
org.mockito.Mockito
javaslang.API
javaslang.Predicates&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_template_to_insert_a_static_logger_instance&#34;&gt;Template to insert a static logger instance&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Go &lt;code&gt;Windows &amp;gt; Preferences &amp;gt; Java &amp;gt; Editor &amp;gt; Templates &amp;gt; New&lt;/code&gt; …&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Enter logger as name and as template:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code&gt;${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Afterwards you’re able to type logger in your code and ctrl+space gives the option to insert the logger&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>IntelliJ Snippets</title>
      <link>https://www.hascode.com/intellij-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/intellij-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_live_templates&#34;&gt;Live Templates&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_junit_5_test&#34;&gt;JUnit 5 Test&lt;/h3&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code&gt;@org.junit.jupiter.api.Test

@org.junit.jupiter.api.DisplayName(&amp;#34;$NAME$&amp;#34;)

void $METHOD$() throws Exception {

    $END$

}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;imageblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;img src=&#34;intellij-junit5-template.png&#34; alt=&#34;intellij junit5 template&#34;/&gt;
&lt;/div&gt;
&lt;div class=&#34;title&#34;&gt;Figure 1. IntelliJ Live Template Editor&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Edit Variables:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;NAME&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;METHOD: &lt;em&gt;default-value camelCase(NAME)&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&#34;imageblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;img src=&#34;intellij-junit5-variables.png&#34; alt=&#34;intellij junit5 variables&#34;/&gt;
&lt;/div&gt;
&lt;div class=&#34;title&#34;&gt;Figure 2. Editing template variables&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_slf4j_logger_template&#34;&gt;SLF4J Logger Template&lt;/h3&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code&gt;private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger( $CLASS$.class );&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Edit variables:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CLASS: &lt;em&gt;expression: className()&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_favorite_shortcuts&#34;&gt;Favorite Shortcuts&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_select_whole_block_in_editor&#34;&gt;Select whole block in Editor&lt;/h3&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;span class=&#34;keyseq&#34;&gt;&lt;kbd&gt;Cmd&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;+&lt;kbd&gt;Down&lt;/kbd&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_select_similar_blocks_in_editor&#34;&gt;Select similar blocks in editor&lt;/h3&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;span class=&#34;keyseq&#34;&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_copy_the_absolute_path_of_the_current_file_into_clipboard&#34;&gt;Copy the absolute Path of the current File into Clipboard&lt;/h3&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;span class=&#34;keyseq&#34;&gt;&lt;kbd&gt;Cmd&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Spring Boot Snippets</title>
      <link>https://www.hascode.com/spring-boot-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/spring-boot-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_define_and_configure_log_groups&#34;&gt;Define and Configure Log Groups&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;admonitionblock tip&#34;&gt;
&lt;table&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;td class=&#34;icon&#34;&gt;
&lt;i class=&#34;fa icon-tip&#34; title=&#34;Tip&#34;&gt;&lt;/i&gt;
&lt;/td&gt;
&lt;td class=&#34;content&#34;&gt;
This allows to configure a group of loggers at the same time
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&#34;olist arabic&#34;&gt;
&lt;ol class=&#34;arabic&#34;&gt;
&lt;li&gt;
&lt;p&gt;Define a log group named &lt;code&gt;myaspect&lt;/code&gt; with two packages&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;title&#34;&gt;application.properties&lt;/div&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-properties&#34; data-lang=&#34;properties&#34;&gt;logging.group.myaspect=com.hascode.package1,com.hascode.package2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure the log group and set all loggers to level &lt;code&gt;TRACE&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;title&#34;&gt;application.properties&lt;/div&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-properties&#34; data-lang=&#34;properties&#34;&gt;logging.level.myaspect=TRACE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This is also possible as parameter on startup&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;java -Dlogging.level.myaspect=TRACE myapp.jar&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_use_junit_5_with_spring_boot&#34;&gt;Use JUnit 5 with Spring Boot&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Use newer versions of Surefire and Failsafe plugins:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&amp;lt;properties&amp;gt;
[..]
  &amp;lt;maven-failsafe-plugin.version&amp;gt;2.22.0&amp;lt;/maven-failsafe-plugin.version&amp;gt;
  &amp;lt;maven-surefire-plugin.version&amp;gt;2.22.0&amp;lt;/maven-surefire-plugin.version&amp;gt;
&amp;lt;/properties&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
