2011-01-21 5 views
7

IntelliJ IDEA의 로그 출력을 확인함으로써, 정렬이 매우 좋았다는 사실을 알았습니다 (다른 클래스 중에서 클래스 이름이 오른쪽 정렬되고 잘려 짐으로 인해).log4j alignment

log4J를 사용하여 어떻게합니까? 특별한 애펜더가 필요 하신가요?

2011-01-08 00:48:53,938 [ 2537] INFO - ellij.vfs.persistent.FSRecords - Marking VFS as corrupted 
2011-01-08 00:48:53,987 [ 2586] INFO - api.vfs.impl.local.FileWatcher - Native file watcher is operational. 
2011-01-08 00:48:54,034 [ 2633] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/other.xml file is null 
2011-01-08 00:48:54,035 [ 2634] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/other.xml 
2011-01-08 00:48:54,046 [ 2645] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/project.default.xml file is null 
2011-01-08 00:48:54,047 [ 2646] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/project.default.xml 
2011-01-08 00:48:54,051 [ 2650] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/options.xml file is null 
2011-01-08 00:48:54,051 [ 2650] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/options.xml 
2011-01-08 00:48:54,295 [ 2894] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/filetypes.xml file is null 
2011-01-08 00:48:54,295 [ 2894] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/filetypes.xml 
2011-01-08 00:48:54,342 [ 2941] INFO - .history.utils.LocalHistoryLog - local history version mismatch (was: 0, expected: 5), rebuilding... 
2011-01-08 00:48:54,342 [ 2941] INFO - .history.utils.LocalHistoryLog - FS has been rebuild, rebuilding local history... 

답변

9

PatternLayout과 같이 할 수 있습니다. 예를 들어, 당신은 로거 카테고리 정의 할 수 있습니다 :이 필드는 항상 다양한 정확히 20 자하는 원인이

%20.20c 

를, 값이 20 자 미만의 경우 공백, 더 큰 경우를 잘라내는 패딩 왼쪽 (20)

보다 귀하의 질문에 로그의 PatternLayout은 일 수 있습니다 뭔가 같은 :

%d [%7.7r] %6.6p - %c{30} - %m%n