Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
すっきり分かる Python のログ
Search
kimihiro_n
October 27, 2017
Technology
6
2.8k
すっきり分かる Python のログ
Python のロガー周りを理解するための資料です。(社内勉強会用)
コードとか:
https://github.com/pistatium/about_python_logging
kimihiro_n
October 27, 2017
Tweet
Share
More Decks by kimihiro_n
See All by kimihiro_n
サービスへの影響を抑えてデータベースの移行を実施したはなしAurora MySQL -> Cloud SQL
pistatium
0
1.2k
新しいメンバーに Make debut してもらいやすくするための開発体制 with Python
pistatium
1
3.4k
たのしい FastAPI
pistatium
1
16k
Other Decks in Technology
See All in Technology
GPSデバイスを使った簡易位置案内システムの構築をしてみた話。/jawsfesta2024
kwada
0
230
カメラ単体で物体の3次元 座標を扱う方法
kenmatsu4
0
170
とある事業会社にとっての Kaggler の魅力
hakubishin3
7
1.6k
サーバレスで挑む IoT プロジェクトの現実解 / Real solutions for the IoT project using serverless service
genkiogasawara
1
130
SOLID - Architecture and Architectural Decisions - Devfest Goa 2024
rivuchk
0
160
Brakeman を欺く - Kashiwa.rb #4
kozy4324
1
100
まだ間に合う! 生成AIトレンド一挙おさらい & AWSのBedrockに入門しよう
minorun365
PRO
4
310
全社を巻き込んだ業務オペレーション改善と、それは事業成長に貢献しているのか?を実感した話
marroooon
0
150
Cosmos DB で持続可能な RAG を実現しよう!~ AOAI Dev Day ふりかえりを添えて / Sustainable RAG with Cosmos DB with recap AOAI Dev Day
miyake
0
180
RDS for Db2 データ移行編 - Part2:S3経由のバックアップ・リストアでデータ移行 /20241011-RDSforDb2-dojo
mayumihirano
0
140
プログラミング写経のすすめ
natsutan
0
170
マルチテナントのサービスインフラに大きなテナントを受け入れるまで
7474
0
790
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The World Runs on Bad Software
bkeepers
PRO
65
11k
How to Ace a Technical Interview
jacobian
275
23k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
Scaling GitHub
holman
458
140k
Facilitating Awesome Meetings
lara
49
6k
Code Reviewing Like a Champion
maltzj
519
39k
What's new in Ruby 2.0
geeforr
342
31k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Transcript
͖ͬ͢Γ͔Δ 1ZUIPOͷϩά @kimihiro_n
1ZUIPOͰਖ਼͘͠ϩά͕ѻ͑ΔΑ͏ʹͳΔ ͞ΑͳΒ1SJOUσόοά ཉ͍͠ϩάΛཉ͍͠Α͏ʹʂ ඞཁͳՕॴʹߜͬͨϩάͷऔΓࠐΈ ϑΝΠϧίϯιʔϧͷग़͚͠ -PHHFSͷΈࣗମଞͷݴޠͰ +BWBͱ͔+BWBͱ͔ log.debug('Hello, logging world!!')
͜ͷൃදͷత
MPHHFSͷॳظԽ ϩάΛ͏ͨΊͷ͓·͡ͳ͍ -PHHFSͱݺΕΔΠϯελϯεΛ࡞Δ ϑΝΠϧ͝ͱʹ࡞ ͱΓ͋͑ͣͬͯΈΔ
ϩάͷॻ͖ࠐΈ -PHHFSΠϯελϯεͷϝιουΛݺͿ͚ͩ ॏཁ߹͍ʹԠͯͭ͡ͷϨϕϧ͕͑Δ ϩάΛॻ͖ࠐΉ
ඪ४Τϥʔग़ྗʹग़͖ͯ·͢ छྨͷϩά͕Ͱʜͯͳ͍ ϩάΛݟΔ This is a Warning message This
is a Error message This is a Critical message
TFU-FWFMͱ͍͏ϝιουͰมߋ σϑΥϧτ8"3/*/( ͜ΕҎԼͷͷແࢹ͞ΕΔ ϨϕϧΛԼ͛ͯΈΔ
݁Ռ This is a Warning message This is a
Error message This is a Critical message
)BOEMFSͱ͍͏ͷΛॳظԽͯ͠ηοτ ͬͪ͜ʹϨϕϧઃఆ͕͋Δ )BOEMFSͳΔͷ
݁Ռ This is a Debug message This is a
Info message This is a Warning message This is a Error message This is a Critical message
-PHHJOHͷ͘͠Έ
__name__ if __name__..ͷ͓·͡ͳ͍Ͱ͓ೃછΈ 1ZUIPO͔ΒݺͿͱ__main__͕ೖΔ JNQPSUͯͬͨ͠߹ ɹ͜ͷϑΝΠϧͷϞδϡʔϧ໊͕ೖΔ NZBQQNPEFMTJUFNTQZͳΒ NZBQQNPEFMTJUFNT͕ೖΔ ͓·͡ͳ͍ͷಾ
HFU-PHHFSͷҾ ࣮จࣈྻͳΒͳΜͰ͍͍ ͨ͠จࣈྻ͕-PHHFSͷ໊લʹ @@OBNF@@ΛຖೖΕͯΔͷ ໊લܾΊΔͷ໘͍͔͘͞Β ศར͔ͩΒ ͓·͡ͳ͍ͷಾ
-PHHFS֊Λ࣋ͯΔ -PHHFSͷ໊લΛ υοτ Ͱ۠Δͱ উखʹ֊Խ͞ΕΔ NZBQQNPEFMTJUFNTͱ͍͏໊લͷ-PHHFS NZBQQNPEFMT NZBQQ SPPU ͷ-PHHFSΛʹ࣋ͭ
-PHHFSͷ֊ؔ
)BOEMFSͷׂ ͖ͬͯͨϩάΛదʹॲཧ͢Δ ෆཁͳϩάͷϑΟϧλʔ ϩάͷϑΥʔϚοτ ग़ྗઌϩάΛૹΔ ͭͷ-PHHFSʹରͯ͠ෳηοτͰ͖Δ MPHHFSBEE)BOEMFS )BOEMFSͱ
4USFBN)BOEMFS ඪ४ग़ྗͳͲͷετϦʔϜʹॻ͖ࠐΉ 'JMF)BOEMFS ϑΝΠϧʹॻ͖ࠐΉ 3PUBUJOH'JMF)BOEMFS 'JMF)BOEMFSͷ3PUBUFͯ͘͠ΕΔ൛ 4.51)BOEMFS ϝʔϧΛૹΔ͍ͭͩ͢͝Α /VMM)BOEMFS Կ͠ͳ͍
΄͔ )BOEMFSͷछྨ
ϩάͷॻࣜΛࢦఆ͢ΔͨΊͷͷ )BOEMFSʹରͯ͠ࢦఆͰ͖Δ ͑ΔมҰཡ IUUQTEPDTQZUIPOKQMJCSBSZ MPHHJOHIUNMMPHSFDPSEBUUSJCVUFT formatter = logging.Formatter( '[%(asctime)s:%(name)s:%(levelname)s] %(message)s'
) handler.setFormatter(formatter) 'PSNBUUFS
IUUQTEPDTQZUIPOKQIPXUPMPHHJOHIUNMVTFGVMIBOEMFST
-PHHFSͷಈ͖ํ جຊͷಈ͖ ࣗͷ)BOEMFSΛݺͼग़͠ ˠͭͷ-PHHFSҠಈ Λ܁Γฦ͢ ʮͷ-PHHFSΛݺͼग़͔͢ʯ MPHHFSQSPQFSHBUF ͱ͍͏ଐੑͰ੍ޚ͍ͯ͠Δ 'BMTFʹ͢ΔͱଧͪΓ σϑΥϧτ5SVF
؆ུԽͷͨΊϑΟϧλʔলུ͍ͯ͠·͢
)BOEMFSͷಈ͖ جຊͷಈ͖ ϩάͷϨϕϧΛΈͯɺ ຬ͍ͨͯͨ͠Βॻ͖ࠐΉ͚ͩ 'PSNBUUFSͰܗͯ͠ɺ ࣗͷॻ͖ࠐΈઌग़ྗ ؆ུԽͷͨΊϑΟϧλʔΛলུ͍ͯ͠·͢
࣮ફฤ
ϩάઃఆͷίʔυ͕͍ ϩάઃఆΛॻ͘ͷ ΤϯτϦϙΠϯτͳͲ͕ଟ͍ ͍ίʔυͰݟ௨͠ѱͨ͘͘͠ͳ͍ ղܾࡦ ผϑΝΠϧʹॻ͍ͯJNQPSUʜʜ˚ ઃఆϑΝΠϧʹͯ͠ಡΈࠐΉʜʜ˓ ͖ͬ͢Γॻ͖͍ͨ
+40/Ͱॻ͍ͯΈΔ EJDU$POpH ઃఆ͕ೖͬͨࣙॻΛ͢ +40/ͷύʔεࣗྗͰ ެࣜ%PDͰ:".- :".-ύʔαʔඇඪ४ +40/ϏϧτΠϯ 'JMF$POpHΛͬͨΓํ
-PHHFS ϩάΛѻ͏ͨΊͷΠϯελϯε ϨϕϧʹΑΔϑΟϧλϦϯά͕Մೳ ֊Խ͞Ε໊ͨલΛ࣋ͭ ͷ-PHHFSͱൖ͢Δ )BOEMFS ϩάͷग़ྗΛཧ͢Δ -PHHFSʹର͠ରଟͰඥ͘ ϨϕϧʹΑΔϑΟϧλϦϯά͕Մೳ ·ͱΊ
-PHHJOH)08501ZUIPOެࣜυΩϡϝϯτ IUUQTEPDTQZUIPOKQIPXUPMPHHJOHIUNM ϩάग़ྗͷͨΊͷQSJOUͱJNQPSUMPHHJOHΊͯ΄͍͠2JJUB IUUQTRJJUBDPNBNFEBNBJUFNTCCGDG ϊʔτϒοΫ IUUQTHJUIVCDPNQJTUBUJVNBCPVU@QZUIPO@MPHHJOHCMPCNBTUFS BCPVU@MPHHJOHJQZOC ࠓճͷ༰ΛKVQZUFSOPUFCPPLܗࣜͰ·ͱΊͯ·͢ ࢀߟ