Home » Tag Archives: Logging (page 3)

Tag Archives: Logging

Your logs are your data: logstash + elasticsearch

logstash-logo

Topic of today’s post stays a bit aside from day-to-day coding and development but nonetheless covers a very important subject: our application log files. Our apps do generate enormous amount of logs which if done right are extremely handy for problems troubleshooting. It’s not a big deal if you have a single application up and running, but nowadays apps, particularity ...

Read More »

Effective Logging in Java/JEE – Mapped Diagnostic Context

java-interview-questions-answers

It all started when i was sitting with a colleague to resolve some application issue, when i noticed something interesting. He was merging the code and my eyes caught the attention of this class “org.apache.log4j.MDC”. This led to few discoveries on the way which  follow here: What is MDC? MDC stands for Mapped Diagnostic Context. It helps you to distinguish ...

Read More »

Mixin in Java with Aspects – for a Scala traits sample

java-interview-questions-answers

Scala traits allow new behaviors to be mixed into a class. Consider two traits to add auditing and version related fields to JPA entities:                   package mvcsample.domain import javax.persistence.Version import scala.reflect.BeanProperty import java.util.Date trait Versionable { @Version @BeanProperty var version: Int = _ } trait Auditable { @BeanProperty var createdAt: Date = ...

Read More »

Spring: Setting Logging Dependencies

spring-interview-questions-answers

This post describes how to set-up logging dependencies in Spring. It is based on information available in a post by Dave Syer’s. A reminder on Java logging frameworks is available here. The code example is available at GitHub in the Spring-Logging-Dependencies directory. Spring uses Jakarta Commons Logging API (JCL). Unfortunately, many people do not like its runtime discovery algorithm. We can disactivate it and ...

Read More »

Grails SQL Logging part 2 – groovy.sql.Sql

grails-logo

I discussed options for logging Hibernate-generated SQL in an earlier post but today I was trying to figure out how to see the SQL from groovy.sql.Sql and didn’t have much luck at first. The core problem is that the Sql class uses a java.util.logging.Logger (JUL) while the rest of the world uses a Log4j logger (often with a Commons Logging or SLF4J ...

Read More »

Logging Hibernate SQL

jboss-hibernate-logo

There are two well-known ways to log Hibernate SQL in Grails; one is to add logSql = true in DataSource.groovy (either in the top-level block for all environments or per-environment)             dataSource { dbCreate = ... url = ... ... logSql = true } and the other is to use a Log4j logging configuration: log4j ...

Read More »

Where do the stack traces come from?

java-logo

I believe that reading and understanding stack traces is an essential skill every programmer should posses in order to effectively troubleshoot problems with every JVM language (see also: Filtering irrelevant stack trace lines in logs and Logging exceptions root cause first). So may we start with a little quiz? Given the following piece of code, which methods will be present ...

Read More »

How to change logging level in runtime

apache-log4j-logo

Changing the log logging level in runtime is important mainly in production environment where you might want to have debug logging for limited amount of time. Well, changing the root logger is very simple – assuming you have an input parameter with the wanted logging level simply get the root logger and set by the input logging level, such as: ...

Read More »

Logback: Logging revisited

logback-logo

Hi, I am back again with my rant about logging as an inherent part of any application design and development. I am a big fan of strong basics, and in my humble opinion logging is one of those often overlooked but basic critical element of any enterprise grade application. I have written about this before here. This is not really ...

Read More »

GlassFish Operations: Log Notifications

oracle-glassfish-logo

The of the most prominent requirements for application servers derive from the operations space. Taking this into account the next Java EE platform specification will focus entirely on platform as a service (PaaS) and cloud operations. Looking at what we have today still leaves a couple of questions unanswered. The one I get asked for quite a lot is: ‘How ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.