우리는 클라이언트 응용 프로그램에서 log4net을 사용하여 생성 된 상대적으로 작은 (500K 미만, 일반적으로 50K 미만으로 읽음) 로그 파일이 많습니다 (읽기 : 50,000). (그들은 야간 또는 업로드 할 때 중 하나).NET에서 프로그램으로 로그 파일 구문 분석
가Start Painless log
Framework:8.1.7.0
Application:8.1.7.0
2010-05-05 19:26:07,678 [Login ] INFO Application.App.OnShowLoginMessage(194) - Validating Credentials...
2010-05-05 19:26:08,686 [1 ] INFO Application.App.OnShowLoginMessage(194) - Checking for Application Updates...
2010-05-05 19:26:08,830 [1 ] INFO Framework.Globals.InstanceStartup(132) - Application Startup
2010-05-05 19:26:09,293 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Purchase History Data>:True
2010-05-05 19:26:09,293 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Shopping Assistant>:True
2010-05-05 19:26:09,294 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Shopping List>:True
2010-05-05 19:26:09,294 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Teeth>:True
2010-05-05 19:26:09,294 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Scanner>:True
2010-05-05 19:26:09,294 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Value Comparison>:True
2010-05-05 19:26:09,294 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Lotus Notes CRM>:True
2010-05-05 19:26:09,295 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Salesforce.com>:False
2010-05-05 19:26:09,295 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Lotus Notes Mail>:True
2010-05-05 19:26:09,295 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Sales Leads>:True
2010-05-05 19:26:09,295 [1 ] INFO Framework.PluginManager.LogPluginState(150) - Plugin <Configurator>:True
2010-05-05 19:26:09,297 [1 ] INFO Application.App.OnShowLoginMessage(194) - Validating Database...
2010-05-05 19:26:10,342 [1 ] INFO Application.App.OnShowLoginMessage(194) - Validating Database...
2010-05-05 19:26:10,489 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Global Handlers...
2010-05-05 19:26:10,495 [1 ] INFO Application.App.OnShowLoginMessage(194) - Starting Main Window...
2010-05-05 19:26:10,496 [1 ] INFO Application.App.OnShowLoginMessage(194) - Initializing Components...
2010-05-05 19:26:11,145 [1 ] INFO Application.App.OnShowLoginMessage(194) - Restoring Location...
2010-05-05 19:26:11,164 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Plug Ins...
2010-05-05 19:26:11,169 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Panels...Order Manager
2010-05-05 19:26:11,181 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Orders...
2010-05-05 19:26:11,274 [1 ] INFO Application.App.OnShowLoginMessage(194) - Done Loading 1 Order
2010-05-05 19:26:11,314 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Panels...All Products
2010-05-05 19:26:11,471 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Purchase History Data
2010-05-05 19:26:11,545 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Shopping List
2010-05-05 19:26:11,597 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Teeth
2010-05-05 19:26:11,768 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Scanner
2010-05-05 19:26:11,810 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Value Comparison
2010-05-05 19:26:11,840 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...Sales Leads
2010-05-05 19:26:11,922 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Tabbed Areas...(Done!)
2010-05-05 19:26:11,923 [1 ] INFO Application.App.OnShowLoginMessage(194) - Adding Handlers...
2010-05-05 19:26:11,925 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Main Window Handlers...
2010-05-05 19:26:11,932 [1 ] INFO Application.App.OnShowLoginMessage(194) - Loading Main Menu...
2010-05-05 19:26:11,949 [1 ] INFO Application.App.OnShowLoginMessage(194) - Initialization Complete.
2010-05-05 19:26:13,662 [1 ] INFO Framework.ProductSearch.Search(342) - User entered term: <>
나는 (항상 오류 또는 FATAL에 로그인) 중 하나 예외를 추출하기 위해 이러한 로그 서버 측 구문 분석 할 수 있도록하고 싶습니다 : 일반적인 로그처럼 보인다 나 같은 다른 특정 로그 메시지 :
2010-05-05 20:05:24,951 [1 ] INFO Framework.ProductSearch.Search(342) - User entered term: <kavo>
그래서 우리는 사람들이 정말이 찾고 무엇인지 찾을 수있는 'KAVO'용어를 얻을 수 있습니다.
나는 String.Split()과 유사한 메소드를 사용하여 손으로 텍스트를 파싱 해봤지만 휠을 재발 명하고있는 것처럼 느껴졌다.
이런 종류의 로그를 추출하는 좋은 라이브러리가 있습니까?
이 아이디어를 중심으로 Serilog (http://serilog.net)가 구축되었습니다. Log.Information ("Hello {0}", "world")'를 쓸 때 형식 문자열과 매개 변수는 별도로 저장되며 표시 용으로 만 렌더링됩니다. 구조화 된 로그 (예 : JSON)를 로깅 텍스트처럼 쉽게 작성합니다. –