

A Bootique Logback Configuration File Example
source link: https://nixmash.com/java/a-bootique-logback-configuration-file-example/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

A Bootique Logback Configuration File Example
Probably every Bootique Application uses the Bootique Logback Module. All of my Bootique Apps do, yet I've always used a logback.xml file instead of a bootique.yml configuration. One of the reasons I stayed with a logback.xml is because I found it easier to add multiple output options. I decided to change my thinking on that, because, first, it was wrong, and secondly, because a bootique.yml can do anything a logback.xml can do.
One problem for me transitioning from logback.xml to bootique.yml was issues I had setting up the YAML configuration file and I couldn't find good examples. I'm adding this post to the Bootique Library In The Sky in an effort to change that.
Before getting to the task at hand, please note that there is excellent documentation on the Bootique Logback Module which covers configuration and much more.
Why Not Use a Logback.xml?
Bootique provides the option of using a logback.xml with a simple useLogbackConfig: true option. The problem is that this is as far as it goes and you cannot specify a location for logback.xml. This prevents configuring your Bootique App on a server-by-server basis, with different logging configuration files for development and production.
On the other hand, your Bootique.yml file can be located anywhere. Here's an example for the NixMash Microservices Web Module (this blog) using an external log.yml configuration file.

Another thing that's beneficial with Bootique Logging is that multiple modules of a Microservice Applications like this blog can share a single log.yml to reduce redundancy. The Post Microservices Module, for instance, can share the same log.yml file as the Web Module.
The Log.yml File
What you've been waiting for, the log.yml configuration example file. If you're familiar with logback.xml you'll see all of the familiar configuration options, only in YAML format instead of XML.
A couple of tips and gotchas. First, the indents are TWO SPACES, not tabs. Also, if you set the logging level to OFF, you have to enclose it is single quotes. I don't know why that is, but for consistency I put all levels in quotes as you see.

We're implementing a File Rolling Policy based on time. You can also set a rolling policy on a Fixed Window basis (file size.) Our time policy is based on the Logging File Format. yyyyMMDD will cause a new logging file to be created each day. Here are the last few days of this blog's logs.

You can set the number of History Files you wish to keep, but as you see in my log.yml I am keeping them all.
Before signing off, you'll find other helpful logging configuration YAML files in the Bootique Logback repository on GitHub.

Happy Logging with Bootique Logback!
Recommend
-
53
bootique - Bootique is a minimally opinionated platform for modern runnable Java apps.
-
63
之前在 日志?聊一聊slf4j吧 这篇文章中聊了下slf4j。本文也从实际的例子出发,针对logback的日志配置进行学习。 logack 简介 logback 官网:https://logback.qos.ch/ 目前还没有看过日志类框架的源码,仅限于如
-
17
java-version.com: What's new in Java 16? 15? Keep up to date! Basic Spring MVC example with Thymeleaf and no XML (annotation based conf...
-
13
A Bootique Command Demo Application Using Bootique Commands is a great way to put together tight little JARs to execute scheduled tasks with cron. We'll cover the basics of building a Bootique Command Application in this post.
-
18
Bearer Token Design in Bootique Shiro for REST Authentication My interest in using Bearer Authentication Tokens in Microservices began after reading
-
39
Single and Multiple File Uploads with Jersey and Bootique You'll find information on uploading single and multiple files with Jersey in many places, but there are a few details I'll emphasize in this post which may prove help...
-
9
Generic Type Injection Examples in Bootique and Guice Back when I was working in Spring I built a Jsoup Annotation-based parsing library which I blogged about here. It...
-
18
NixMash.com is built with the Bootique Java Framework. Modules include Bootique Shiro, Jersey, RabbitMQ Client, MVC, Logback and Jetty. Bootique 0.25 was just released so I didn't waste any time upgrading....
-
9
In this post I'm going to demonstrate using RabbitMQ RPC with the Bootique RabbitMQ Module. You can find RabbitMQ RPC examples elsewhere like in the RabbitMQ Java Examp...
-
7
Example configuration for fluentd-es namespace per index using record_modifier and elasticsearch · GitHub Instantly share code,...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK