java's People
java's Issues
Custom Logger Utility
org.slf4j.Logger
plugin logger를 만들기엔 조사할 로거들이 많음.
- logback
- log4j
- tinylog
- etc.
아마 다른 로거들도 독립적으로 구현하고, xxx-to-slf4j
로 변환할 것으로 추측된다.
따라서 보통 그냥 진짜 단순한 로거를 작성하자.
나중에 마일스톤 따고, 제대로 만들자.
TODO
- ConsoleAppender
- FileAppender
- AsyncAppender
- KafkaAppender
- RedisAppender
- etc.
[Logger] how to get max class name length
reflection 기능을 활용하여 TestLogger
를 참조하는 클래스의 이름들을 추출하고, 그 이름의 최대 길이를 측정하여 log format 조절.
private static final int MAX_NAME_LENGTH;
static {
// TODO
List<Class> classes = scanClasses(TestLogger.class);
int maxNameLength = classes.stream().mapToInt(clazz -> clazz.getSimpleName().length()).max();
int threshold = 20;
MAX_NAME_LENGTH = Math.min(threshold, maxNameLength)
}
// ...
formatWithLength(name, MAX_NAME_LENGTH);
Logging appender builder
Appender
생성 시 Builder Pattern 형식으로 Custom Logging Appender를 생성할 수 있다.- enum Appender Types
- Console
- File
// example
new AppenderBuilder(AppenderType.CONSOLE)
.level(Level.DEBUG)
.pattern(new PatternBuilder().timestamp("HH:mm:ss.SSS").thread(20).level(5).name().build())
.build();
Appender self logging levels
Appender
자체 로깅 레벨을 설정할 수 있게 설정- 전역 로깅 레벨(
global logging level
) 설정 시 강제할 수 있음(logging.level.force = [true|false(default)]
Appender
자체 로깅 레벨 설정 값이 없을 경우 전역 로깅 레벨을 따라감
Logging Publish & Subscribe pattern
- Logger 객체는 로그를 찍을 때마다 Event 객체를 생성한다.
- 생성된 Event 객체를 EventHandler에 전달한다.
- EventHandler는 등록된 여러 Appender에 다시 Event를 전달한다. (
Publish
) - Appender는 구독하고 있던 EventHandler로부터 Event를 전달받는다. (
Subscribe
) - 각 Appender는 비동기로 동작하여 main thread에 영향을 미치지 않게 한다.
[Logger] rename `TestLoggger` to `ConsoleLogger`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.