This file contains hidden or 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 Logger { | |
| // private constructor to avoid instantiation (Point #1) | |
| private Logger(){} | |
| // Private static variable to ensure single instance (Point #2) | |
| private static Logger loggerInstance; | |
| // Global Access point for private static instance (Point #3) | |
| public static Logger getInstance(){ |
This file contains hidden or 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
| /* | |
| * Solution for Thread Safe Implementation in Multi Threaded | |
| * environment -- Synchronized Keyword | |
| */ | |
| public class ThreadSafeLogger { | |
| private static ThreadSafeLogger loggerInstance; | |
| private ThreadSafeLogger(){} | |
This file contains hidden or 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
| /* | |
| * Solution for Thread Safe Implementation in Multi Threaded | |
| * environment -- Bill Pugh Implementation | |
| */ | |
| public class ThreadSafeLogger { | |
| private static class InstanceHolder { | |
| static final ThreadSafeLogger INSTANCE = new ThreadSafeLogger(); | |
| } | |
| public static ThreadSafeLogger getInstance() { | |
| return InstanceHolder.INSTANCE; |
This file contains hidden or 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
| Class loggerClazz = Logger.class; | |
| Constructor constructor = loggerClazz.getDeclaredConstructor(); | |
| constructor.setAccessible(true); |
This file contains hidden or 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 logging.aspects; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.aspectj.lang.JoinPoint; | |
| import org.aspectj.lang.ProceedingJoinPoint; | |
| import org.aspectj.lang.annotation.*; | |
| import org.jboss.logging.MDC; | |
| import org.springframework.context.annotation.Configuration; | |
| import utility.mapper.AppObjectMapper; // remove this import if do not want to use utility dependency from my multi-module projec |
This file contains hidden or 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 logging.aspects; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.aspectj.lang.JoinPoint; | |
| import org.aspectj.lang.ProceedingJoinPoint; | |
| import org.aspectj.lang.annotation.*; | |
| import org.jboss.logging.MDC; | |
| import org.springframework.context.annotation.Configuration; | |
| import utility.mapper.AppObjectMapper; // remove this import if do not want to use utility dependency from my multi-module project |
This file contains hidden or 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 logging.aspects; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.aspectj.lang.JoinPoint; | |
| import org.aspectj.lang.ProceedingJoinPoint; | |
| import org.aspectj.lang.annotation.*; | |
| import org.jboss.logging.MDC; | |
| import org.springframework.context.annotation.Configuration; | |
| import utility.mapper.AppObjectMapper; // remove this import if do not want to use utility dependency from my multi-module project |
This file contains hidden or 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 logging.annotations; | |
| import java.lang.annotation.ElementType; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| import java.lang.annotation.Target; | |
| @Target ({ElementType.METHOD, ElementType.CONSTRUCTOR}) | |
| @Retention (RetentionPolicy.RUNTIME) | |
| public @interface Loggable { |
This file contains hidden or 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 apidocs.config; | |
| import lombok.AllArgsConstructor; | |
| import org.springframework.beans.factory.annotation.Value; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import springfox.documentation.builders.PathSelectors; | |
| import springfox.documentation.builders.RequestHandlerSelectors; | |
| import springfox.documentation.service.*; | |
| import springfox.documentation.spi.DocumentationType; |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <configuration> | |
| <include resource="org/springframework/boot/logging/logback/defaults.xml"/> | |
| <appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender"> | |
| <encoder class="net.logstash.logback.encoder.LogstashEncoder"> | |
| <fieldNames> | |
| <levelValue>[ignore]</levelValue> | |
| <version>[ignore]</version> | |
| </fieldNames> | |
OlderNewer