This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stopwatch stopwatch = new Stopwatch(); | |
for (int i = 0 ; i < 1000 ; i++) { | |
JMS_LOGGER.info("Message sent to the configured appender."); | |
} | |
double elapsedTime = stopwatch.elapsedTimeInMillis(); | |
LOGGER.info("LOGGER.info() method took {} ms to execute", String.format("%1.12f", elapsedTime)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); | |
if (loggerFactory instanceof LoggerContext) { | |
LoggerContext context = (LoggerContext) loggerFactory; | |
context.stop(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | |
<layout class="ch.qos.logback.classic.PatternLayout"> | |
<Pattern>%date [%thread] %-5level %logger{25} - %msg%n</Pattern> | |
</layout> | |
</appender> | |
<appender name="file" class="ch.qos.logback.core.FileAppender"> | |
<file>logs/main.log</file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory | |
java.naming.provider.url = tcp://localhost:61616 | |
connectionFactoryNames = queueConnectionFactory | |
queue.my-logback-queue = queue.logback-queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
private static final String JMS_LOGGER_CATEGORY = "JMS_LOGGER"; | |
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class); | |
private static final Logger JMS_LOGGER = LoggerFactory.getLogger(JMS_LOGGER_CATEGORY); | |
public static void main(String[] args) { | |
Stopwatch stopwatch = new Stopwatch(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class SimpleListener { | |
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleListener.class); | |
@JmsListener(destination = "queue.logback-queue") | |
public void receiveOrder(Message message) throws JMSException { | |
LoggingEventVO loggingEventVO = (LoggingEventVO) ((ActiveMQObjectMessage)message).getObject(); | |
LOGGER.info("Message '{}' received.", loggingEventVO.getMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class br.org.roger.lombok.Person { | |
public java.lang.String getName(); | |
public java.lang.String getLastName(); | |
public java.util.Date getDateOfBirth(); | |
public java.lang.String getAddress(); | |
public void setName(java.lang.String); | |
public void setLastName(java.lang.String); | |
public void setDateOfBirth(java.util.Date); | |
public void setAddress(java.lang.String); | |
public boolean equals(java.lang.Object); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.org.roger.lombok; | |
import java.util.Date; | |
import lombok.EqualsAndHashCode; | |
import lombok.Getter; | |
import lombok.NoArgsConstructor; | |
import lombok.ToString; | |
@NoArgsConstructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
public class PersonBoilerPlateCode { | |
private String name; | |
private String lastName; | |
private Date dateOfBirth; | |
private String address; | |
public PersonBoilerPlateCode() { | |
super(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
import lombok.Data; | |
public @Data class Person { | |
private String name; | |
private String lastName; | |
private Date dateOfBirth; | |
private String address; | |
} |