Penna
Featherweight JSON Logging for the JVM
What is Penna?
Penna is a fast and lightweight slf4j implementation that writes structured JSON log messages to stdout. You can read more here.
When should I use Penna?
Penna is specially useful for when you run you applications on docker containers or kubernetes pods and your log is captured from stdout to a log aggregator like loki or the elastic stack.
Adding Penna to your project
- Add the latest version of
penna-core
to your dependency manager.
// gradle
runtimeOnly 'com.hkupty.penna:penna-core:0.8.1'
<!-- maven -->
<dependency>
<groupId>com.hkupty.penna</groupId>
<artifactId>penna-core</artifactId>
<version>0.8.1</version>
</dependency>
Logging is supposed to provide meaningful information and, with the evolution of log processing platforms, it is oftentimes difficult to convey the right information as written, natural text, in a way that it both makes sense for humans and is easy for machines to process.
Instead, we should embrace the notion that logs are effectively data and should be treated as such.
Penna comes packed with a sane defaults configuration that allows one to plug it and start using immediately. Although configuration is possible, by rolling with the shipped defaults one can already reap the benefits of structured logging without having to set up any configuration.
The logging framework should not draw out much attention. It should just work. With that in mind, penna tries to be a simple yet effective component in your architecture. It should not require you to add in more dependencies. Instead, it should work with whatever you have available.
Also, it should make its best effort to consume the fewer resources as possible, being efficient and sparing your app of GC pauses when under heavy load. Read more on our performance tests.
The latest news and articles about penna
- 2024-10-23 | Why I Believe in Open Source
The tale of a lone wanderer
Before we jump into the reasoning, I want to take a step back to walk you through my train of thought, as I believe it would feel out of place to present those ideas without telling a bit of my background, just as a painting’s meaning deepens when we know the artist’s story.
I’m a self-taught engineer with around two decades worth of experience in the software industry. Most of my knowledge and experience was acquired through contact and use of OSS (open-source software). Many such technologies I never invested a single cent to have access to. Over the years I have professionally worked with over a dozen different languages, most of which in the JVM. Not only that, but everything ranging from neovim to kubernetes, that I use daily, was made available to me (well, to us) for free.
Read more - 2024-10-22 | 0.8.1 Release
As a one-man project, things usually tend to move slowly, but thankfully there are amazing people out there with a keen eye and generous heart proving open-source is the best way for software development!
Read more - 2024-03-24 | Performance insights: Engineering for high performance
This is the second article in our series of Penna’s performance insights. If you haven’t checked the first one yet, make sure to have a look!
I’ll take advantage of the recent release of the 0.8.x series to kick off this article and talk a little more as to how Penna manages to achieve really good numbers when compared to other slf4j backends.
Read more - 2024-03-20 | 0.8 Release
Almost two seasons ago, Penna the 0.7 branch began and now, 289 commits later, a new and even more exciting chapter begins. Version 0.8 is soon released with exciting features and a great deal of improvement!
Read more - 2024-02-13 | The importance of structured logging
Why log in JSON?
In my previous article I wrote how to write your logs in JSON and gave a brief description to why you would want to do that, but in this one I want to dive a little deeper in this subject as there are plenty of reasons to do that.
What is structured logging?
You might recognize traditional log messages as strings containing a timestamp:
1
2024-02-13T21:48:50 [main] INFO com.your.app.Logger - Your log message
This one line contains multiple pieces of data that have meaning and are formatted together in a human readable string.
Read more - 2024-01-31 | JSON logs for the JVM
How to output JSON logs?
Use Penna. I know, you’re used to setting up XML files and configuring encoders, formatters and whatnot for having your logs output in JSON, so it sounds too simple, right?
Well, it is, but it wouldn’t be deserving an article if it was that obvious. The hard part here is that Penna is not as known as Log4j or Logback, so naturally you’re skeptical.
So, by the end of article, you’ll surely have enough confidence on what Penna is and what problems it solves that you’d be willing to give it a try.
Read more - 2023-11-29 | Performance insights: Guards, Time and Modern Java Features
A while ago I promised to go a little more in detail on the performance of Penna. There are quite a few interesting techniques in play for such high numbers to be achieved and nothing is too fancy or extreme that wouldn’t be useful outside, so it makes sense to go a bit in detail as it can be useful for other projects.
Read more - 2023-11-15 | 0.7.1 Release
A couple weeks after the 0.7 release I’m excited to announce the first patch release of 0.7.x series.
The theme of this release is a single, yet important, improvement: Thread safety.
In this post I’m going to dive deeper in the architecture of this change.
Read more - 2023-10-29 | 0.7 Release
It’s autumn already and many things happened since Penna was announced and latest activity surfaced. This doesn’t mean that Penna stalled, just that a lot of work has been happening in the background.
And it is now time to announce the great new features & improvements that are expected to be in this exciting 0.7 release!
Read more - 2023-06-05 | Why Penna?
Why?
Back in January this year I started asking myself this question: “Can I make logging better?”. Well, better is a fun word, as it seams to mean so much, and yet nothing concrete at the same time.
Read more