Long story short: i can't get a custom level to work in spring boot.
using log4j is not a requirement; Internet basically pointed me in this direction.
The issues i have:
1 - Adding log4j2 to the project
I've added log4j2 starter to the depdencencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
...and excluded logback from spring-boot-starter-parent, as mentioned in all tutorials:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
..then i add a property logging.config: userstream/src/main/resources/log4j2.xml pointing to where i keep the log4j2 config.
2 Configuring log4j2 (as i have no idea - complicated!)
i figured out i start simple, as what i want is just ONE extra loglevel called "BUSINESS", to log events that are not WARN but also not INFO:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<CustomLevels>
<CustomLevel name="BUSINESS" intLevel="850" />
</CustomLevels>
</Configuration>
... ( now HELP me please - what do i need to configure here to get it running?)
3 Calling it (should work like this, but right now doesn't!)
private static final Logger LOGGER = LogManager.getLogger(UserStreamApplication.class);
....
LOGGER.log(Level.forName("BUSINESS", 850), "mystreamFunction called by user"+ uid);
Been running this up-and-down since hours, every config looks different and each tutorial has an subjectively different approach. Don't want to mess with fileappenders and logformats etc at all. Just want to have an level between INFO and WARN that i can use. KISS!
Im asking you veteran log4j warriors and spring-boot superstars for help!