LOG.debug("nice catch!") - connpass
2012/06/27 java-ja 『LOG.debug("nice catch!")』#java_ja #javaja - Togetterまとめ
blogã¨ã³ããªãæ¸ãã¾ã§ãjava-jaã ã¨èããã®ã§ã¨ããããæ¸ããè¶ ã¾ã¨ã¾ã£ã¦ã¾ãããåã¹ãã¼ã«ã¼ã®è©±ã®å 容ã«ã¤ãã¦ã¯ä»ã®äººã®blogã«(ãã¶ã)æ¸ãã¦ããã®ã§ãã£ã¡ãè¦ãã¨ãTogetterãçºããã¨ãããã°ããã®ã§ã¯ãªãã§ããããã
主å¬ã®ã¿ãªãã¾ãããã³ä¼å ´æä¾ã®GREEãã¾ããããã¨ããããã¾ãããããããã°GREEã§ã®åå¼·ä¼ã£ã¦åãã¦åå ããæ°ããããå æ¬æ¨ãã«ãºã®å ¥é¤¨ãã ãã¶ç°¡åã«ãªãã¾ãããã
ãã£ã¦ãã
ã©ã£ã¡ãã¨ããã¨ã¢ããªã±ã¼ã·ã§ã³ã®ã³ã¼ãæ¸ã人ãå¤ãã£ããã§ããããã¨ããæãã§ãã¢ããªã±ã¼ã·ã§ã³ã³ã¼ãããããã«ãã¦ä¾å¤ãæãããããããã©ã®ããã«ãã°ã«æ®ãããã¨ããè¦ç¹ã®è©±ãå¤ãã£ãã
ã¢ããªã±ã¼ã·ã§ã³ã®ãã¸ãã¹ãã¸ãã¯å±¤ãã©ã®ããã«ãã°ãæ®ãã¹ããã¨ããã®ã¯ãã¾ãåé¡ã®ã¯æããªã*1ãã§åé¡æèã®ãºã¬ããã£ã¦ãèªåã«ã¯ä½ãåé¡è¦ããã¦ããã ã£ããã¨ããã®ããã¾ãã¡ããã£ã¦ãªãã¦ãå²ã¨ã¼ãããèãã¦ãå°è±¡ãããããã¼ãï¼
@t_wada ããã®ãTDDããã£ã¦ããã¨ãã°åºåãå¿ãããã¨ããçºè¨ã極ãã¦å°è±¡ã«æ®ã£ã¦ããããè¦ããã«ãã¾ããããªãå¥ã«ãã°è¦ããã®ã ã¨æããã ãããâ¦â¦ã¨ãã話ã¯ãã¨ã§ããããã詳ããæ¸ãã
ãã¨ã§é£ã¹ç©ã¨ããªããå°ã話ããå
容ãªãã ãã©ãã¨ã©ã¼ã¨ããã®ã¯ã ãããã¢ã¸ã¥ã¼ã«ã¨ã¢ã¸ã¥ã¼ã«ã®éãã·ã¹ãã ã¨ã·ã¹ãã ã®éãWebã¢ããªã±ã¼ã·ã§ã³ã¨ããã¯ã¨ã³ãã®éã§èµ·ãããã®ã§ãããããã¨ããã«ã¤ãã¦æåããã¼ã¿ã®ãã§ãã¯ã¨(æªãããªç¶æ
ã«ã¤ãã¦ã®)詳細ãªãã®ã³ã°ããã£ã¦ããã°ããããããªãããªãããå¢çãã¯ãã°åºåã«ããã¦éè¦ã§ãããã¨ããã®ãããããã°è©±ã«ããã¾ããããããã¯æ¬å½ã«ããã ã¨æãã
ã¨ãã㧠@t_wada ããã®ç´¹ä»ããã¦ãããæ°´è²ã¬ã³ã¬æ¬ãããã¨ã§ã¡ãã£ã¨è¦ãã¦ããã ãããã ãã©ã ãã¶è¯ããããªæ¬ã ã£ãããã¡ãã¨æèã®éç¨ãè¨è¨æéã®åææ¡ä»¶ãè°è«ããä¸ã§è¨è¨ãã©ã®ããã«ãã¹ãããã®ããã«æ´ç¶ã¨æ§æãçµã¾ãã¦ãæããããæ¬æããã©è¦ããéãã§ã¯è°è«ã®çµã¿ç«ã¦ãåç« ã§ç°¡æ½ã«ç¬ç«ããè¨è¿°ã«ãªã£ã¦ããããã ã£ãã®ã§ãæ°ã«ãªã£ãç« ã ãæ¾ã£ã¦èªãã«ãããããã«æãããããã¯è²·ãã¤ããã*2
ããã¹ã£ã¦ãã
ããã°ãæ®ãæ¹æ³ã¨ãã¦ãããããã®ã使ãæ¹æ³ãããã¾ããã¨å¤ªä¸ã㨠@ryushi ãããç´¹ä»ãã¦ããã®ãããã¸ãæ°ã«ãªã£ãã®ã§ãæå¾ã«é£ã³è¾¼ã¿ã§LTãã£ã¦ãããè³æç¡ãã§é©å½ã«ãã©ã¦ã¶ã«ã¿ããããã¤ãéãã¦è¡¨ç¤ºããã¦ããã¦ããã¹ãã¹ã¿ã¤ã«ã
話ã®å
容ã¯ä»¥ä¸ã®éãã
- logrotateãã¸ã¡ããã¨ãããªãã¨æ²åãèµ·ãã
- scribedã¨ãããã®ãããããããã«åºæ¬çã«æ å ±ã¯ç¡ã
- scribedã®ã¤ã³ã¹ãã¼ã«ã¯å¤§å¤
- scribedã®ã¤ã³ã¹ãã¼ã«ã¯ãã¸å¤§å¤
- scribedã¯ãããã大å¤éããã®ã§é¿ããã»ãããã
- ã¨ãããããªãã¨ã こちらのエントリ ã«æ¸ãã¦ããã®ã§èå³ãããã°èªãã®ãããã§ããã
- fluentdã¤ã¤ã¨ï¼
ãã®ãããªè©±ãããã¨ããå¿ãªãææ³ã(éåå è ãã)å¯ãããã¾ãããã²ã©ãï¼
tagomorisããï¼å®å ¨ã«Fluentdè¸äººåãã¦ãã
ãã¸ã¬ã¹ããã¨ããã¡ããåã話ã¯äºåº¦ããªãããã«æ°ãã¤ãã¦ãããã ãå®ã¯ããscribedã²ã©ããã£ã¦è©±ã¯ã¾ã ã©ãã§ããã¦ããªãã£ãã¯ãï¼
éç¨ã®è¦ç¹ããããã°ã®è©±
ç¶æ ãæªãããªã¨ãã¯warnãåºããã ãåºãã°ããã¨æããerrorãåºããªã奴ã¯xxxxã ï¼ã¿ãããªã®ã¯ã¾ããã*3ã¨ãã¦ãinfoã¬ãã«ã®ãã°ã«ã¤ãã¦ã
ãæ¬çªã§INFOåºããªãã®ã¯éç¨è ã®ãã¨èãã¦ãªããï¼ã #java_ja
ãæ¬å½ã«éç¨è ã®ãã¨ãèãããªã "ãã°ãªããè¦ããª" ã¨è¨ãã¾ãã #java_ja
åè
ãä¼å ´ããã®ããã³ã( @yoshiori ããã ã£ãããª)ãå¾è
ã¯ããã«å¯¾ãã¦ã® @ryushi ããã®è¿çã ã£ãã¨æããããã«ã¤ãã¦ã¯èªåãå®å
¨ã«åæã§ããã§ããã®ãããã®è©³ãã話ã
ãªããããã¯ã·ã§ã³ç°å¢ã®è©±ã§ããéçºæã¯éçºè
ã好ãã«ããã°ããã¨æãã¾ãã
ã¾ãåºæ¬çã«ãéç¨è ãæ®æ®µããINFOãã°ãè¦ããã¨ã¯ç¡ãã¨æããã²ã¨ã¤ã®ãµã¼ãã¹å°å±ã®éç¨æ å½ã§ãã¤æ¯æ¥ãããã¦ãã¨ããªãã¨ããããä»ã«åªå é ä½é«ããã®ããããã§ãããã®ã§ãã¾ãè¦ãªããè¦ã¦ãã£ã¦äººããï¼
ãªã®ã§ãINFOãã°ãè¦ã¦ãããæ£ããç¶æ³ãªã®ãã©ãããå¤æãããã¨ã¯æ®éã¯ã§ããªãããã§ãããç¡çããã¨ãã°è¡ãããã¹ãéè¦ãªå¦çãã²ã¨ã¤é£ã°ããã¦ãã¦ãã®åã®INFOãã°ãåºã¦ãªãã¦ããã¾ãæ°ä»ããªããã©ãããããã®å¦çã¯ã¹ããããã¦ãã£ã¡ã«è¡ãããã¨ããINFOãã°ãåºã¦ãã¦ããããèªãã§ç°å¸¸*4ã ã¨å¤æããã®ã¯ä¸å¯è½ã ã*5
ã¾ãä½ããã®ãã©ãã«æã«INFOãã°ãåºãã¦ãããã¨ã§ä½ãå©ãããã¨ããã¨ãä½ãå©ãããªããæ£ããWARN/ERRORãåºåããã¦ããç¶æ³ãªããã°ãã¡ã¤ã«ã¯WARN/ERRORã«æº¢ãã¦ãã¦ãããããæ ¹æ¬çãªåå ããã©ãã ãã§ç²¾ä¸æ¯ã ãè¤æ°ã®ã¢ã¸ã¥ã¼ã«ãçµåãã£ã¦æ§æããã¦ããé常ã®ã¢ããªã±ã¼ã·ã§ã³ã®å ´åã¯åé¡ãèµ·ããã¦ããã¢ã¸ã¥ã¼ã«ä»¥å¤ããã大éã®ã¨ã©ã¼ãã°ãåºã¦ããã®ã§ãã©ããå®éã«åé¡ã«ãªã£ã¦ããã®ãã調ã¹ãã ãã§ãã²ã¨è¦å´ã
ã§ãããã«INFOãã°ã大éã«æº¢ãã¦ã¦ãè¦ã¦ãããªããããããã£ã«ã¿ã®æéãå¢ããã ããªã®ã§ããã¦ãã¯éªéããªãåé¡ã®åå ã«ã¤ãã¦å¤§æ ã§è¦å½ãã¤ããå ´åã«ã¯ããããã詳細ãè¦ãã®ã«INFOãã°ãå½¹ã«ç«ã¤å ´åããããã©ãããããã¢ããªã±ã¼ã·ã§ã³ã®ã½ã¼ã¹ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã§grepããã»ãã解決ãæ©ãå ´åãå¤ãããããªãã§ãããããåè¿°ããéããINFOãã°ã¯ãã©ãããåºã¦ããã®ãæ£ããããç¥ã£ã¦ããªãã¨å½¹ã«ã¯ç«ããªããããããã©ãã«æã«ãããªã®èª¿ã¹ã¦ãããªãã§ããã
èªåã®æè¦ã¨ãã¦ã¯ã(å½ç¶ã¢ã¯ã»ã¹ãã°ãè¡åãã°ã¯å¥ã¨ãã¦)ã¢ããªã±ã¼ã·ã§ã³ãã°ã¯ãä½ããªããã°ä½ãåºãªããã®ããã¡ã°ãèªç¶ã ããä½ãåºã¦ãªããã°ããããä½äºãç¡ããã ãªãã¨å¤æããã
ã¨ãããã¨ã§ãèªå㯠WARN/ERROR ã ãåºã¦ãã°ãããæ´¾ã§ãããããINFOã®ãã¨èããããããã£ããWARNãæåããã¦ã»ããã
éç¨ã®è¦ç¹ããããããå¦çã®è©±
ãªãä¼å ´ã§ä¸è¨ã®è©±é¡ã«é¢é£ãã¦ä»¥ä¸ã®ãããªè©±ãåºã¦ãã
ãINFOãã°åºãã¦ããã¨ãã°å®æçã«èµ·åãã¦ãªãã¨å°ããããã®éå§ã¨çµäºã®ãã°ãéç¨ã®äººã«ç£è¦ãã¦ãããã¨ãã
ããããªãã ããããã¯ãªãã絶対ãªãããããªãã¨ã¢ããªæ¸ã人ãè¨ãã ãããã誰ãããæ¤ åæãããã¦ãããããããªããªã¼ã¨ã«ãããã«è¦å®ãã¬ãã«ããªããªãã
ã¸ã§ãã®èµ·åã¨åæ¢ã®å¶å¾¡ã¨ããã®ã¯ãããå¦çãã®ãã®ã®ä¸å¿çãªæ©è½ã®ã²ã¨ã¤ã§ãã¾ãã¢ããªã±ã¼ã·ã§ã³ã®è¦ä»¶ã¨ãã¦æ±ºããã¹ãéè¦ãªè¦ç´ ã§ãããã5åã«1åèµ·åããã¸ã§ããã¨ãããã®ãããã¨ãã¦ããã®èµ·åã¨åæ¢ã«ã¯ä»¥ä¸ã®ããã«æ§ã ãªè¦ç´ ãã¢ããªã±ã¼ã·ã§ã³è¦ä»¶ã¨ãã¦æ±ºãã¦ããå¿ è¦ãããã
- 1ã¸ã§ãã5åãè¶
ãã(ãããã¯è¶
ãããã«ãªã£ã)ã¨ãããã®ã¸ã§ãã¯ãã®ã¾ã¾ç¶ç¶ãã¹ãããåæ¢ãã¹ããï¼
- ã¾ããã®ç¶æ³ã¯æ£å¸¸ç¶æ ããç°å¸¸ç¶æ ãï¼
- åã®ã¸ã§ããç°å¸¸ç¶æ ã ã£ãã¨ãã次ã®ã¸ã§ãã¯èµ·åãã¦ãã¾ã£ã¦ãè¯ããï¼
- åã®ã¸ã§ãã5åãè¶
ãã¦èµ°ã£ã¦ããã¨ãã次ã®ã¸ã§ãã¯ã©ããã¹ããï¼
- åã®ã¸ã§ãã®ãã¨ã¯æ°ã«ãããã®ã¾ã¾éå§ãã¹ãï¼
- åã®ã¸ã§ããå®äºããã¾ã§å¾ æ©ããããããåä½ãéå§ãã¹ãï¼
- åã®ã¸ã§ããkillãã¦èªåã¯éå§ãã¹ãï¼
- èªåã¯éå§ããªã(é»ã£ã¦çµäºãã)ã¹ãï¼
- ã§ããã®ç¶æ ã¯ç°å¸¸ç¶æ ï¼ æ£å¸¸ç¶æ ï¼
極ãã¦ç°¡åãªã¨ãããæããã ãã§ãããã®ããªã¨ã¼ã·ã§ã³ããããã¾ããããã¯ãã¹ã¦ã¢ããªã±ã¼ã·ã§ã³ã®è¦æ±ã«ãã£ã¦æ±ºã¾ããæ¡ä»¶ã¨ãã¦ã¯ä»ã«ããæå¾ã«ãã¼ã¿ãæ´æ°ããã¦ãã30åãããªãã¸ã§ãã«ãã£ã¦ãæ´æ°ããªããã°ç°å¸¸ãã®ããã«ãã¼ã¿ããªãã³ã§ã®ç£è¦ãå¿
è¦ãªã±ã¼ã¹ãããã
ã¾ããåã®ã¸ã§ããã次ã®ã¸ã§ããã¯ãµã¼ããã¾ããã§åå¨ããå¯è½æ§ããããã¨ã«ã注æããå¿
è¦ããããããå½ç¶ãã©ã³ã¶ã¯ã·ã§ãã«ãªå¶å¾¡ãå¿
è¦ã¨ãããã¨ãå¤ãã
ã¨ãããã¨ã§ããããå¦çãæ£å¸¸ã«èµ°ã£ããã©ãããINFOãã°ãç¨ãã¦ç£è¦ããã¨ãè¨èªéæããã®ãããªãã¨ã«ã¯å
¨ãæå³ããªãã
ã¢ããªã±ã¼ã·ã§ã³éçºè
ã§ãªãããã®ãããå¦çãæ¸ããã¨ã«ãªã£ã人ã¯ãã®ãã¨ããã¡ãã¨å¿µé ã«ç½®ãã¦ãå®è¡å±¥æ´ããã¡ãã¨RDBMSãªããªããªãã§ç®¡çãããã®æ
å ±ããã¡ãã¨ã¢ããªã±ã¼ã·ã§ã³ã®è¦ä»¶ã«å¾ã£ã¦æ£å¸¸/ç°å¸¸ãå¤å®ããããã°ã©ã ãæ¸ãã¦ããã®å®è¡çµæãç£è¦ãã¼ã«ã«çªã£è¾¼ã¿ã¾ãããã
*1:ç¡ãã¦ããããããããã¨ããããå¿ è¦ãªãã¼ã¿ãªãããã¯ã¢ããªã±ã¼ã·ã§ã³ãè¨é²ããä»ã®ãã¼ã¿ã¨åãããã«æ®ãã°ãããããããã¨æã
*2:ã¨ã¯ããå ¨é¨éãã¦èªãã¨ããããã«ããªãã ãããªãããµã³ãã«ã³ã¼ãã«Adaãåºã¦ããã®ãè¦ã¦ããã¼Adaã®ä»æ§æ¸ã£ã¦ã¢ãã¿ããã«ååãã£ã¦è©±ãèãããã¨ããããªã¼ãã¿ããã«æã£ã¦ãã
*3:ãã°ã®å®¹éã«ã¤ãã¦â¦â¦ã¨ãã話ããã£ããã©ãããããlogrotateãã¡ããã¨ãã£ã¦ããã°åé¡ã«ãªããªããä¿åæéã¨ããè¨ããã¦ããã©ãä»æã«ããã¯ã¢ãããã¦ããã§ä¿åæéã¯èãããããããªãã¨ãµã¼ãé£ãã ãçµããã ããã¨æãã
*4:ãããã¯ç°å¸¸ã«è¿ãä½ããã®ç¶æ³
*5:ãã®ãããªã±ã¼ã¹ã§ããã«æ³¨æãã¦ã»ããã®ã§ããã°ãããã¯INFOã§ã¯ãªãWARNãªãERRORãªãã§åºãã¹ãã