Upgrade to Pro — share decks privately, control downloads, hide ads and more …

#渋谷java - Logback の Appender を実装してみよう

#渋谷java - Logback の Appender を実装してみよう

第九回 渋谷 Java の飛び入り LT で発表した資料です。
http://shibuya-java.connpass.com/event/9996/

E77287648aff5484ac7659748e45c936?s=128

KOMIYA Atsushi

December 13, 2014
Tweet

Transcript

  1. Logback ͷ Appender Λ ࣮૷ͯ͠ΈΑ͏ ୈ۝ճ #ौ୩java 2014-12-13 at BizReach

    @komiya_atsushi
  2. ͓·ͩΕ

  3. ,0.*:""UTVTIJ !LPNJZB@BUTVTIJ

  4. None
  5. None
  6. ʮੈքதͷྑ࣭ͳ৘ใΛඞཁͳਓʹૹΓಧ͚Δʯ ͨΊʹɺौ୩ɾࡩٰொͰ ೔ʑδϟόδϟό͍ͯ͠·͢

  7. None
  8. None
  9. ͦ͏͍͏Θ͚Ͱ

  10. ΈΜͳ͍͖ͩ͢ Logback ͷ Appender Λ࣮૷ͯ͠Έ·͠ΐ͏

  11. None
  12. IUUQRJJUBDPNNBDIJUFNTB⒎DBBDBD

  13. ࣾ಺ͷ৘ใڞ༗ͷେ൒͸ Slack ্

  14. αʔόͷҟৗঢ়ଶΛ௨஌͢Δ ઌ΋౰વ Slack

  15. Java ΞϓϦέʔγϣϯͷ ࣮ߦதʹҟৗ͕ੜͨ͡ͱ͖΋ɺ Slack Ͱ೺Ѳ͍ͨ͠ʂ

  16. Logback ܦ༝Ͱ Slack ʹ ϝοηʔδΛϙετ͍ͨ͠ʂ

  17. How to

  18. 1. Slack API Λୟͨ͘Ίͷ τʔΫϯΛऔಘ͢Δ

  19. http://qiita.com/punchdrunker/items/db9c824397e3affbb210

  20. ͖͞΄Ͳ·Ͱ๻΋ ͭ·͍ͮͯ·ͨ͠ (>_<)

  21. 2. Appender Λ࣮૷͢Δ

  22. جఈΫϥεΛ࢖͍·͠ΐ͏ • AppenderBase<ILoggingEvent>   • ࠓճ͸ͪ͜ΒΛ࢖ͬͯΈͨ • UnsynchronizedAppenderBase
 <ILoggingEvent>  

    • ͨͿΜͪ͜ΒΛ࢖͏΂͖
  23. HTTP(S) ௨৴͢Δॲཧ͸ඇಉظͰ • HTTP(S) ͰϦΫΤετΛ౤͛Δͷ͸͕͔͔࣌ؒΔ… • Appender ಺ͰεϨουΛ্ཱͪ͛ͯɺϩάΠϕϯτ ΛΩϡʔܦ༝ͰϝΠϯεϨου͔Βڙڅͯ͠΋Β͓͏ •

    ΈΜͳ͍͖ͩ͢ Producer-Consumer ύλʔϯ • ϩάΠϕϯτ͕ Slack ্Ͱલޙ͢Δͷ͸Α͘ͳ͍Α Ͷ
  24. ΞϓϦέʔγϣϯऴྃ࣌ͷ஫ҙ • Consumer ͷεϨου͸σʔϞϯεϨουʹ͠ਏ͍ • Thread#setDaemon()   • ϩάΠϕϯτ͕ϩάΒΕͣʹফࣦͯ͠͠·͏ࣄଶ͸ආ͚͍ͨ •

    AppenderBase#stop() ΛΦʔόʔϥΠυ͢Ε͹Αͦ͞͏ʁ • ࣮ࡍ͸ɺ͜ͷࢠ͸ΞϓϦέʔγϣϯऴྃ࣌ʹݺͼग़͞ΕΔΘ ͚Ͱ͸ͳ͍…ʁϩάϝοηʔδ͕ Slack ্Ͱલޙ͢Δͷ͸Α ͘ͳ͍͠
  25. ΞϓϦέʔγϣϯऴྃ࣌ͷ஫ҙ • ࢓ํͳ͍ͷͰɺҎԼͷΑ͏ͳϔϧύʔϝιο υΛఏڙ͓ͯ͠஡Λ୙͢͜ͱʹ • ࠜຊతͳղܾํ๏ืूத

  26. 3. logback.xml ͰઃఆͰ͖Δ ࢓૊ΈΛఏڙ͢Δ

  27. ͱͬͯ΋؆୯ • Appender ࣮૷ΫϥεʹϓϩύςΟ (getter/ setter) Λ༻ҙ͢Ε͹ OK • ޙͰίʔυΛ͓ݟͤ͠·͢

  28. logback.xml Ͱͷઃఆ͸͜Μͳײ͡

  29. σϞ

  30. ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ʂ