{"id":76,"title":"G\u00fcnl\u00fck Kayd\u0131 \u0130\u00e7in G\u00fcvenli ve Etkin Y\u00f6ntem: logger Komutu","content":"Linux sistemlerde g\u00fcnl\u00fck dosyalar\u0131na mesaj yazmak, sistem izleme, hata ay\u0131klama ve g\u00fcvenlik denetimi i\u00e7in kritik \u00f6neme sahiptir. Ancak, bu i\u015flem genellikle s\u00fcper kullan\u0131c\u0131 (<code >root<\/code>) ayr\u0131cal\u0131klar\u0131 gerektirir \u00e7\u00fcnk\u00fc <code >\/var\/log<\/code> dizini alt\u0131ndaki dosyalar genellikle k\u00f6k kullan\u0131c\u0131s\u0131na aittir. Bu yaz\u0131da, <strong><code >logger<\/code> komutunun <\/strong>, s\u00fcper kullan\u0131c\u0131 izni olmadan g\u00fcnl\u00fck dosyas\u0131na g\u00fcvenli bir \u015fekilde mesaj yazman\u0131n en iyi yoludur, logger Komutu Nedir? logger, sistem g\u00fcnl\u00fck mekanizmas\u0131 (syslog) \u00fczerinden mesajlar\u0131 g\u00fcnl\u00fc\u011fe kaydetmek i\u00e7in kullan\u0131lan komut sat\u0131r\u0131 arac\u0131d\u0131r. Temel i\u015flevi, kullan\u0131c\u0131 tan\u0131ml\u0131 mesajlar\u0131 sistem g\u00fcnl\u00fc\u011f\u00fcne g\u00f6ndermektir. <pre  data-enlighter-language=\"generic\">logger \"Bu bir test mesaj\u0131d\u0131r.\"<\/pre> <p data-spm-anchor->Bu komut, mesaj\u0131 sistem g\u00fcnl\u00fc\u011f\u00fcne a\u015fa\u011f\u0131daki gibi kaydeder:<\/p> <div> <div  dir=\"ltr\"> <pre  data-enlighter-language=\"generic\">OCT 15 10:30:00 hostname user.notice: Bu bir test mesaj\u0131d\u0131r.<\/pre> <strong> Neden logger Tercih Edilmelidir?<\/strong> <strong>Sistem G\u00fcnl\u00fc\u011f\u00fc Mekanizmas\u0131n\u0131 Kullan\u0131r<\/strong> logger, do\u011frudan g\u00fcnl\u00fck dosyas\u0131na yazmak yerine syslog hizmetini (\u00f6rne\u011fin, rsyslog veya syslog-ng) kullan\u0131r. Bu, mesajlar\u0131n sistem y\u00f6neticisinin tan\u0131mlad\u0131\u011f\u0131 kurallara g\u00f6re y\u00f6nlendirilmesini sa\u011flar (\u00f6rne\u011fin, \/etc\/rsyslog.conf). <strong>S\u00fcper Kullan\u0131c\u0131 Ayr\u0131cal\u0131\u011f\u0131 Gerekmez<\/strong> logger, sistem g\u00fcnl\u00fc\u011f\u00fcne mesaj g\u00f6ndermek i\u00e7in UNIX soketi (\/dev\/log) \u00fczerinden ileti\u015fim kurar. Bu soket, varsay\u0131lan olarak t\u00fcm kullan\u0131c\u0131lar i\u00e7in yaz\u0131labilirdir. Bu nedenle, sudo olmadan mesaj yaz\u0131labilir. <\/div> <h4><strong data-spm-anchor->Otomatik Zaman Damgas\u0131 ve Seviye Etiketi<\/strong><\/h4> logger, mesajlara otomatik olarak zaman damgas\u0131 ve seviye etiketi (\u00f6rne\u011fin, user.notice) ekler. Bu, manuel zaman damgas\u0131 ekleme ihtiyac\u0131n\u0131 ortadan kald\u0131r\u0131r ve g\u00fcnl\u00fcklerin tutarl\u0131l\u0131\u011f\u0131n\u0131 sa\u011flar. <\/div> <strong>G\u00fcnl\u00fck Rotasyonu ve Y\u00f6netimi<\/strong> logger ile yaz\u0131lan mesajlar, sistem g\u00fcnl\u00fc\u011f\u00fc altyap\u0131s\u0131 taraf\u0131ndan y\u00f6netilir. Bu, g\u00fcnl\u00fck dosyalar\u0131n\u0131n logrotate gibi ara\u00e7larla otomatik olarak s\u0131k\u0131\u015ft\u0131r\u0131lmas\u0131, ar\u015fivlenmesi ve silinmesini sa\u011flar. <strong> G\u00fcvenli ve Kontroll\u00fc Eri\u015fim<\/strong> logger, g\u00fcnl\u00fck dosyas\u0131na do\u011frudan eri\u015fim gerektirmedi\u011fi i\u00e7in dosya izinleriyle ilgili sorunlar\u0131 \u00f6nler . Sistem y\u00f6neticisi, syslog yap\u0131land\u0131rmas\u0131yla hangi kullan\u0131c\u0131lar\u0131n hangi mesajlar\u0131 g\u00f6nderebilece\u011fini kontrol edebilir. <h3><strong data-spm-anchor->Alternatif Y\u00f6ntemler ve S\u0131n\u0131rl\u0131l\u0131klar\u0131<\/strong><\/h3> <div > <div > <table > <thead > <tr > <th  scope=\"col\"> <div ><strong>Komut<\/strong><\/div><\/th> <th  scope=\"col\"> <div ><strong>Kullan\u0131m \u00d6rne\u011fi<\/strong><\/div><\/th> <th  scope=\"col\"> <div ><strong>Sorunlar<\/strong><\/div><\/th> <\/tr> <\/thead> <tbody> <tr > <td > <div ><strong><code >echo<\/code><\/strong><\/div><\/td> <td > <div ><code >echo \"$(date) Test mesaj\u0131\" &gt;&gt; \/var\/log\/custom.log<\/code><\/div><\/td> <td > <div ><code >\/var\/log\/custom.log<\/code>dosyas\u0131na yazma izni gereklidir (genellikle<code >root<\/code>).<\/div><\/td> <\/tr> <tr > <td > <div ><strong><code >cat<\/code><\/strong><\/div><\/td> <td > <div ><code >cat message.txt &gt; \/var\/log\/custom.log<\/code><\/div><\/td> <td > <div >Dosya izinleri ve<code >sudo<\/code>gereksinimi.<\/div><\/td> <\/tr> <tr > <td > <div ><strong><code >touch<\/code><\/strong><\/div><\/td> <td > <div ><code >touch \/var\/log\/custom.log<\/code><\/div><\/td> <td > <div  data-spm-anchor->Yaln\u0131zca dosya olu\u015fturur, i\u00e7erik yazmaz.<\/div><\/td> <\/tr> <\/tbody> <\/table> <\/div> Bu komutlar, do\u011frudan dosya sistemine yazma i\u015flemi yapt\u0131\u011f\u0131 i\u00e7in g\u00fcvenlik riskleri ta\u015f\u0131r ve y\u00f6netim zorlu\u011fu yarat\u0131r. <strong>logger Komutunun Geli\u015fmi\u015f Kullan\u0131m\u0131<\/strong> \u00d6zel Kolayl\u0131k (Facility) ve Seviye (Priority) Tan\u0131mlama <pre  data-enlighter-language=\"generic\">logger -p local7.info \"\u00d6zel kolayl\u0131k mesaj\u0131\"<\/pre> -p se\u00e7ene\u011fi, kolayl\u0131k (\u00f6rne\u011fin, local0\u2013local7) ve seviye (\u00f6rne\u011fin, info, debug) tan\u0131mlar. Bu, mesajlar\u0131n \u00f6zel g\u00fcnl\u00fck dosyalar\u0131na y\u00f6nlendirilmesini sa\u011flar. <strong>PID (Process ID) Ekleme<\/strong> <pre  data-enlighter-language=\"generic\">logger -i \"Bu mesaj PID ile kaydedilecek.\"<\/pre> -i se\u00e7ene\u011fi, mesaj\u0131n sonuna i\u015flem kimli\u011fini ekler. <strong>Syslog A\u011f Sunucusuna G\u00f6nderme<\/strong> rsyslog veya syslog-ng yap\u0131land\u0131rmas\u0131yla, mesajlar uzak bir g\u00fcnl\u00fck sunucusuna y\u00f6nlendirilebilir. Bu, merkezi g\u00fcnl\u00fck y\u00f6netimi i\u00e7in idealdir. <h3><strong>Troubleshooting \/ Sorun giderme:<\/strong><\/h3> <div > <div ><\/div> <\/div> <\/div> <table > <thead > <tr > <th  scope=\"col\"> <div ><strong>Soru<\/strong><\/div><\/th> <th  scope=\"col\"> <div ><strong>\u00c7\u00f6z\u00fcm<\/strong><\/div><\/th> <\/tr> <\/thead> <tbody> <tr > <td > <div ><strong><code >logger<\/code>\u00a0Mesajlar\u0131 Nerede G\u00f6r\u00fcn\u00fcyor?<\/strong><\/div><\/td> <td > <div ><code >\/var\/log\/syslog<\/code>veya<code >\/var\/log\/messages<\/code>dosyalar\u0131n\u0131 inceleyin.<\/div><\/td> <\/tr> <tr > <td > <div ><strong>Mesajlar Beklenildi\u011fi Gibi Y\u00f6nlendirilmiyor Mu?<\/strong><\/div><\/td> <td > <div ><code >\/etc\/rsyslog.conf<\/code>veya<code >\/etc\/syslog-ng\/syslog-ng.conf<\/code>yap\u0131land\u0131rmas\u0131n\u0131 g\u00f6zden ge\u00e7irin.<\/div><\/td> <\/tr> <tr > <td > <div ><strong><code >logger: socket failed: Operation not permitted<\/code>\u00a0Hatas\u0131 Al\u0131n\u0131yor Mu?<\/strong><\/div><\/td> <td > <div ><code >rsyslog<\/code>veya<code >syslog<\/code>hizmetinin \u00e7al\u0131\u015f\u0131p \u00e7al\u0131\u015fmad\u0131\u011f\u0131n\u0131 kontrol edin (<code >systemctl status rsyslog<\/code>)<\/div><\/td> <\/tr> <\/tbody> <\/table> &nbsp; logger komutu, s\u00fcper kullan\u0131c\u0131 ayr\u0131cal\u0131klar\u0131 olmadan g\u00fcnl\u00fck dosyas\u0131na mesaj yazman\u0131n en g\u00fcvenli ve etkili yoludur. Sistem g\u00fcnl\u00fc\u011f\u00fc mekanizmas\u0131 \u00fczerinden \u00e7al\u0131\u015ft\u0131\u011f\u0131 i\u00e7in dosya izinleriyle ilgili sorunlardan ka\u00e7\u0131n\u0131r ve g\u00fcnl\u00fck y\u00f6netimi i\u00e7in geli\u015fmi\u015f \u00f6zellikler sunar. Alternatif komutlar hem g\u00fcvenlik riskleri ta\u015f\u0131r hem de sistem g\u00fcnl\u00fc\u011f\u00fc altyap\u0131s\u0131yla uyumlu de\u011fildir. Bu nedenle, g\u00fcnl\u00fck kayd\u0131 gerektiren i\u015flemlerde logger komutu tercih edilmelidir. G\u00fcnl\u00fck mesajlar\u0131n\u0131z\u0131 test etmek i\u00e7in tail -f \/var\/log\/syslog komutunu kullanarak ger\u00e7ek zamanl\u0131 olarak izleyebilirsiniz.","excerpt":"Linux sistemlerde g\u00fcnl\u00fck dosyalar\u0131na mesaj yazmak, sistem izleme, hata ay\u0131klama ve g\u00fcvenlik denetimi i\u00e7in kritik \u00f6neme sahiptir. Ancak, bu...","created_at":"2025-05-01 14:23:02","updated_at":"2026-09-08 00:56:12","category_id":10,"view_count":779,"reading_time":4,"status":"published","editor_choice":0,"is_editor_choice":0,"published_at":"2025-05-01 14:23:02","featured_image":"resimyok.jpg","slug":"gunluk-kaydi-icin-guvenli-ve-etkin-yontem-logger-komutu","category_name":"nix Linux Unix","category_slug":"nix-linux-unix"}