logs.html.ko.euc-kr 29 KB
Newer Older
powelld's avatar
powelld committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
<?xml version="1.0" encoding="EUC-KR"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko"><head>
<meta content="text/html; charset=EUC-KR" http-equiv="Content-Type" />
<!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -->
<title>로그파일 - Apache HTTP Server Version 2.4</title>
<link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" />
<script src="./style/scripts/prettify.min.js" type="text/javascript">
</script>

<link href="./images/favicon.ico" rel="shortcut icon" /></head>
<body id="manual-page"><div id="page-header">
<p class="menu"><a href="./mod/">모듈</a> | <a href="./mod/directives.html">지시어들</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">용어</a> | <a href="./sitemap.html">사이트맵</a></p>
<p class="apache">Apache HTTP Server Version 2.4</p>
<img alt="" src="./images/feather.png" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.4</a></div><div id="page-content"><div id="preamble"><h1>로그파일</h1>
<div class="toplang">
<p><span>가능한 언어: </span><a href="./en/logs.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./fr/logs.html" hreflang="fr" rel="alternate" title="Fran&#231;ais">&nbsp;fr&nbsp;</a> |
<a href="./ja/logs.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/logs.html" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/logs.html" hreflang="tr" rel="alternate" title="T&#252;rk&#231;e">&nbsp;tr&nbsp;</a></p>
</div>
<div class="outofdate">이 문서는 최신판 번역이 아닙니다.
            최근에 변경된 내용은 영어 문서를 참고하세요.</div>

    <p>효율적으로 웹서버를 관리하려면 발생하는 문제와 함께 서버의
    활동과 성능에 대해 알아야 한다. 아파치 웹서버는 매우 종합적이고
    유연한 로그 기능을 제공한다. 이 문서는 로그 기능을 설정하는
    방법과 로그에 들어갈 내용을 설명한다.</p>
  </div>
<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#security">보안 경고</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#errorlog">오류 로그 (Error Log)</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#accesslog">접근 로그 (Access Log)</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#rotation">로그 순환 (Log Rotation)</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#piped">로그를 파이프로 보내기</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#virtualhost">가상호스트</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#other">다른 로그파일</a></li>
</ul><h3>참고</h3><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="security" id="security">보안 경고</a></h2>
    

    <p>누군가에게 아파치의 로그파일이 있는 디렉토리에 쓰기권한이
    있다면 (보통 root) 서버를 실행하는 uid를 거의 확실히 얻을
    수 있다. 이를 고려하지않고 로그가 저장된 디렉토리에 쓰기권한을
    주지 <em>마라</em>. 자세한 내용은 <a href="misc/security_tips.html">보안 팁</a> 문서를 참고하라.</p>

    <p>또, 클라이언트가 제공한 정보는 로그파일에 거의 그대로
    기록된다. 그래서 악의가 있는 클라이언트가 로그파일에 제어문자를
    넣을 수 있으므로, 로그를 다룰때는 주의해야 한다.</p>
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="errorlog" id="errorlog">오류 로그 (Error Log)</a></h2>
    

    <table class="related"><tr><th>관련된 모듈</th><th>관련된 지시어</th></tr><tr><td /><td><ul><li><code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code></li><li><code class="directive"><a href="./mod/core.html#loglevel">LogLevel</a></code></li></ul></td></tr></table>

    <p><code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code> 지시어는
    가장 중요한 로그파일인 서버 오류 로그의 이름과 위치를 지정한다.
    아파치 웹서버는 이 파일에 진단정보와 요청을 처리하는 도중
    발생한 오류를 기록한다. 서버가 시작하거나 동작하는데 문제가
    있다면 무엇이 잘못되었고 때때로 어떻게 고치는지를 알려주는
    이곳을 가장 먼저 살펴봐야 한다.</p>

    <p>오류 로그는 보통 (전형적으로 유닉스 시스템에서는
    <code>error_log</code>, 윈도우즈와 OS/2에서는
    <code>error.log</code>) 파일에 기록된다. 유닉스 시스템에서
    서버는 오류를 <code>syslog</code><a href="#piped">파이프를
    사용하여 다른 프로그램</a>으로 보낼 수도 있다.</p>

    <p>오류 로그의 형식은 상대적으로 자유롭고 자세하다. 그러나
    대부분의 오류 로그 항목에 공통적으로 나오는 정보가 있다.
    예를 들어, 항목은 보통 다음과 같다.</p>

    <div class="example"><p><code>
      [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1]
      client denied by server configuration:
      /export/home/live/ap/htdocs/test
    </code></p></div>

    <p>로그 항목에서 첫번째 항목은 날짜와 시간이다. 두번째
    항목은 보고하는 오류의 심각성을 나타낸다. <code class="directive"><a href="./mod/core.html#loglevel">LogLevel</a></code> 지시어로 오류 로그에
    기록되는 오류의 심각성을 제한할 수 있다. 세번째 항목은
    오류를 발생한 클라이언트의 IP 주소이다. 이 다음부터 오류문이
    나오며, 이 경우 서버가 클라이언트의 접근을 거부하도록
    설정되었다고 나와있다. 요청한 문서의 (웹 경로가 아닌)
    파일시스템 경로도 보인다.</p>

    <p>오류 로그에는 매우 다양한 종류의 문구가 나올 수 있다.
    대부분은 위와 비슷하다. CGI 스크립트의 디버깅 출력도 오류
    로그에 기록된다. CGI 스크립트가 <code>stderr</code>에 쓴
    정보는 그대로 오류 로그로 복사된다.</p>

    <p>오류 로그에 정보를 추가하가나 생략할 수 없다. 그러나
    요청에 대한 오류 로그의 경우 <a href="#accesslog">접근
    로그</a>에도 대응하는 항목이 생긴다. 예를 들어, 위의 경우
    상태코드가 403인 접근 로그 항목이 생긴다. 접근 로그는
    사용자정의할 수 있으므로 이 파일을 참고하여 오류 상황에
    대한 추가정보를 얻을 수 있다.</p>

    <p>검사할때 어떤 문제가 생기는지 오류 로그를 계속 살펴보는
    것이 좋다. 유닉스 시스템에서 다음과 같이 한다:</p>

    <div class="example"><p><code>
      tail -f error_log
    </code></p></div>
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="accesslog" id="accesslog">접근 로그 (Access Log)</a></h2>
    

    <table class="related"><tr><th>관련된 모듈</th><th>관련된 지시어</th></tr><tr><td><ul><li><code class="module"><a href="./mod/mod_log_config.html">mod_log_config</a></code></li><li><code class="module"><a href="./mod/mod_setenvif.html">mod_setenvif</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code></li><li><code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code></li><li><code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code></li></ul></td></tr></table>

    <p>서버 접근 로그는 서버가 처리하는 모든 요청을 기록한다.
    <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
    지시어는 접근 로그의 위치와 내용을 지정한다. <code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code> 지시어를
    사용하여 로그에 포함할 내용을 쉽게 선택할 수 있다. 이 절은
    서버가 접근 로그에 쓸 내용을 설정하는 방법을 설명한다.</p>

    <p>물론 접근 로그에 정보를 기록하는 것은 로그 관리의 시작일
    뿐이다. 다음 단계는 이 정보를 분석하여 유용한 통계를 만드는
    것이다. 이 문서는 일반적인 로그 분석에 대해서 다루지 않으며,
    로그 분석은 실제 웹서버가 할 일이 아니다. 로그 분석에 대한
    정보와 로그를 분석하는 소프트웨어에 대해서는 <a href="http://dmoz.org/Computers/Software/Internet/Site_Management/Log_Analysis/">Open Directory</a>
    참고하라.</p>

    <p>아파치 웹서버는 이전부터 mod_log_referer, mod_log_agent,
    <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
    같은 모듈과 지시어를 사용하여 접근 로그를 다루었다. 지금은
    <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
    지시어가 오래된 지시어들의 모든 기능을 이어받았다.</p>

    <p>접근 로그의 형식은 매우 사용자정의 가능하다. 형식은 C의
    printf(1) 형식문자열과 매우 유사한 형식문자열을 사용하여
    지정한다. 다음 절에 예를 들었다. 형식문자열에 사용가능한
    모든 내용을 알려면 <code class="module"><a href="./mod/mod_log_config.html">mod_log_config</a></code> <a href="mod/mod_log_config.html#formats">형식문자열</a>
    참고하라.</p>

    <h3><a name="common" id="common">Common 로그 형식</a></h3>
      

      <p>접근 로그의 전형적인 설정은 다음과 같다.</p>

      <div class="example"><p><code>
        LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
         CustomLog logs/access_log common
      </code></p></div>

      <p>그러면 지정한 로그 형식문자열을 <em>별명</em>
      <code>common</code>으로 정의한다. 형식문자열은 퍼센트
      지시어들로 구성되며, 각각은 어떤 정보를 기록할지 알린다.
      형식문자열에 일반 문자를 적으면 그대로 로그에 출력된다.
      따옴표 문자(<code>"</code>)를 출력하고 싶다면 백슬래쉬를
      앞에 붙여서 형식문자열의 끝이 아님을 표시한다. 형식문자열에
      줄바꿈 "<code>\n</code>", 탭 "<code>\t</code>"와 같은
      특수 조절문자를 사용할 수 있다.</p>

      <p><code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
      지시어는 정의한 <em>별명</em>을 사용하는 새로운 로그파일을
      만든다. 접근 로그의 파일명이 슬래쉬로 시작하지않으면
      <code class="directive"><a href="./mod/core.html#serverroot">ServerRoot</a></code>의 상대경로이다.</p>

      <p>앞의 설정은 공통로그형식(Common Log Format, CLF)이라는
      형식으로 로그 항목을 기록한다. 여러 다른 웹서버들도 이런
      표준 형식으로 로그를 만들며, 여러 로그 분석 프로그램에서
      읽을 수 있다.  CLF로 만든 로그파일 항목은 다음과 같다:</p>

      <div class="example"><p><code>
        127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
        /apache_pb.gif HTTP/1.0" 200 2326
      </code></p></div>

      <p>이제 로그 항목의 각 부분을 설명한다.</p>

      <dl>
        <dt><code>127.0.0.1</code> (<code>%h</code>)</dt>

        <dd>서버에 요청을 한 클라이언트(원격 호스트)의 IP
        주소이다. <code class="directive"><a href="./mod/core.html#hostnamelookups">HostnameLookups</a></code>
        <code>On</code>이라면 호스트명을 찾아서 IP 주소 자리에
        대신 쓴다. 그러나 이 설정은 서버를 매우 느리게 할 수
        있으므로 추천하지 않는다. 호스트명을 알려면 대신 나중에
        <a href="programs/logresolve.html">logresolve</a>
        같은 로그를 처리하는 프로그램을 사용하는 것이 좋다.
        여기에 나온 IP 주소는 사용자가 사용하는 컴퓨터 주소가
        아닐 수 있다. 프록시 서버가 사용자와 서버사이에 존재한다면,
        원래 컴퓨터 주소가 아니라 프록시의 주소가 기록될 것이다.</dd>

        <dt><code>-</code> (<code>%l</code>)</dt>

        <dd>출력에서 "빼기기호"는 요청한 정보가 없음을 나타낸다.
        이 경우 여기에 나올 정보는 클라이언트 컴퓨터의
        <code>identd</code>가 제공할 클라이언트의 RFC 1413
        신원이다. 이 정보는 매우 믿을 수 없기때문에, 긴밀히
        관리되는 내부 네트웍이 아니라면 절대로 이 정보를 사용하면
        안된다. <code class="directive"><a href="./mod/core.html#identitycheck">IdentityCheck</a></code>
        <code>On</code>이 아니라면 아파치 웹서버는 이 정보를
        알아보려고 시도하지도 않는다.</dd>

        <dt><code>frank</code> (<code>%u</code>)</dt>

        <dd>이는 HTTP 인증으로 알아낸 문서를 요청한 사용자의
        userid이다. 보통 이 값은 CGI 스크립트에게
        <code>REMOTE_USER</code> 환경변수로 넘겨진다. 요청의
        상태코드가 401이라면 (아래 참고) 사용자가 아직 인증을
        거치지 않았으므로 이 값을 믿으면 안된다. 문서를 암호로
        보호하지 않는다면 이 항목은 이전 항목과 같이
        "<code>-</code>"이다.</dd>

        <dt><code>[10/Oct/2000:13:55:36 -0700]</code>
        (<code>%t</code>)</dt>

        <dd>
          서버가 요청처리를 마친 시간.
          형식은:

          <p class="indent">
            <code>[day/month/year:hour:minute:second zone]<br />
             day = 숫자 2개<br />
             month = 숫자 3개<br />
             year = 숫자 4개<br />
             hour = 숫자 2개<br />
             minute = 숫자 2개<br />
             second = 숫자 2개<br />
             zone = (`+' | `-') 숫자 4개</code>
          </p>
          로그 형식문자열에 <code>%{format}t</code>를 사용하여
          다른 형식으로 시간을 출력할 수 있다. <code>format</code>
          C 표준 라이브러리의 <code>strftime(3)</code>과 같다.
        </dd>

        <dt><code>"GET /apache_pb.gif HTTP/1.0"</code>
        (<code>\"%r\"</code>)</dt>

        <dd>클라이언트의 요청줄이 쌍따옴표로 묶여있다. 요청줄은
        매우 유용한 정보를 담고 있다. 첫째, 클라이언트가 사용한
        메써드는 <code>GET</code>이다. 둘째, 클라이언트는 자원
        <code>/apache_pb.gif</code>를 요청한다. 세번째, 클라이언트는
        <code>HTTP/1.0</code> 프로토콜을 사용한다. 요청줄의
        여러 부분을 따로 로그할 수도 있다. 예를 들어, 형식문자열
        "<code>%m %U%q %H</code>"은 "<code>%r</code>"과 똑같이
        메써드, 경로, 질의문자열, 프로토콜을 로그한다.</dd>

        <dt><code>200</code> (<code>%&gt;s</code>)</dt>

        <dd>이는 서버가 클라이언트에게 보내는 상태코드이다. 이
        정보는 (2로 시작하는 코드) 요청이 성공하였는지, (4로
        시작하는 코드) 클라이언트에 오류가 있는지, (5로 시작하는
        코드) 서버에 오류가 있는지 알려주므로 매우 중요하다.
        상태코드의 전체 목록은 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.txt">HTTP
        규약</a> (RFC2616 section 10)에서 찾을 수 있다.</dd>

        <dt><code>2326</code> (<code>%b</code>)</dt>

        <dd>마지막 항목은 응답 헤더를 제외하고 클라이언트에게
        보내는 내용의 크기를 나타낸다. 클라이언트에게 보내는
        내용이 없다면 이 값은 "<code>-</code>"이다. 내용이
        없는 경우 "<code>0</code>"을 로그하려면 대신
        <code>%B</code>를 사용한다.</dd>
      </dl>
    

    <h3><a name="combined" id="combined">Combined 로그 형식</a></h3>
      

      <p>자주 사용되는 다른 형식문자열은 결합된로그형식(Combined
      Log Format)이다. 다음과 같이 사용한다.</p>

      <div class="example"><p><code>
        LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
        \"%{User-agent}i\"" combined<br />
         CustomLog log/access_log combined
      </code></p></div>

      <p>이 형식은 두 항목을 더 추가한 것을 제외하고는 Common
      로그 형식과 완전히 같다. 추가된 항목들은 퍼센트 지시어
      <code>%{<em>header</em>}i</code>를 사용한다. 여기서
      <em>header</em> 자리에  HTTP 요청 헤더 이름이 나올 수
      있다. 이 형식의 접근 로그는 다음과 같다:</p>

      <div class="example"><p><code>
        127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
        /apache_pb.gif HTTP/1.0" 200 2326
        "http://www.example.com/start.html" "Mozilla/4.08 [en]
        (Win98; I ;Nav)"
      </code></p></div>

      <p>추가된 항목은:</p>

      <dl>
        <dt><code>"http://www.example.com/start.html"</code>
        (<code>\"%{Referer}i\"</code>)</dt>

        <dd>"Referer" (맞춤법 틀리지않았음) HTTP 요청 헤더.
        클라이언트가 참조했다고 서버에게 알린 사이트이다.
        (즉, <code>/apache_pb.gif</code>를 링크하였거나 포함한
        사이트이다.)</dd>

        <dt><code>"Mozilla/4.08 [en] (Win98; I ;Nav)"</code>
        (<code>\"%{User-agent}i\"</code>)</dt>

        <dd>User-Agent HTTP 요청 헤더. 클라이언트 브라우저가
        자신에 대해 알리는 식별정보이다.</dd>
      </dl>
    

    <h3><a name="multiple" id="multiple">여러 접근 로그</a></h3>
      

      <p>설정파일에 여러 <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> 지시어를
      사용하면 접근 로그가 여러개 만들어진다. 예를 들어, 다음
      설정은 세가지 접근 로그를 만든다. 첫번째는 기본 CLF 정보를
      기록하고, 두번째와 세번째는 referer와 브라우저 정보를
      기록한다. 마지막 두 <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> 줄은 어떻게
      이전 <code>ReferLog</code><code>AgentLog</code> 지시어의
      기능을 흉내낼 수 있는지 보여준다.</p>

      <div class="example"><p><code>
        LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
        CustomLog logs/access_log common<br />
        CustomLog logs/referer_log "%{Referer}i -&gt; %U"<br />
        CustomLog logs/agent_log "%{User-agent}i"
      </code></p></div>

      <p>또, 이 예는 <code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code>으로 반드시
      별명을 정의할 필요는 없음을 보여준다. 대신 <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> 지시어에
      직접 로그 형식을 지정할 수 있다.</p>
    

    <h3><a name="conditional" id="conditional">조건부 로그</a></h3>
      

      <p>클라이언트 요청의 성격에 따라 해당 항목을 접근 로그에
      기록하지않고 싶을 때가 있다. <a href="env.html">환경변수</a>
      사용하면 쉽게 해결된다. 먼저, 클라이언트가 특정 조건을
      만족하면 환경변수를 설정한다. 이 작업에는 보통 <code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>를 사용한다.
      그리고 <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
      지시어에 <code>env=</code>을 사용하여 환경변수 유무에
      따라 요청을 집어넣거나 뺀다. 예를 들면:</p>

      <div class="example"><p><code>
        # loop-back 인터페이스에서 요청을 표시한다<br />
        SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog<br />
        # robots.txt 파일에 대한 요청을 표시한다<br />
        SetEnvIf Request_URI "^/robots\.txt$" dontlog<br />
        # 나머지를 로그에 남긴다<br />
        CustomLog logs/access_log common env=!dontlog
      </code></p></div>

      <p>다른 예로 영어권 사용자의 요청만을 한 로그파일에 기록하고,
      비영어권 사용자의 요청은 다른 로그파일에 기록하는 경우를
      생각해보자.</p>

      <div class="example"><p><code>
        SetEnvIf Accept-Language "en" english<br />
        CustomLog logs/english_log common env=english<br />
        CustomLog logs/non_english_log common env=!english
      </code></p></div>

      <p>조건부 로그는 매우 강력하고 유연하지만, 이것이 로그
      내용을 조절하는 유일한 방법은 아니다. 로그파일은 서버의
      모든 행동을 기록할때 더 유용하다. 나중에 원하지않는 요청을
      제외하고 로그파일을 분석하는 것이 더 쉽다.</p>
    
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="rotation" id="rotation">로그 순환 (Log Rotation)</a></h2>
    

    <p>조금 바쁜 서버조차도 로그파일에 저장되는 정보량은 매우
    많다. 접속 로그는 보통 만번 요청당 1MB 이상 증가한다. 결과적으로
    기존의 로그를 옮기거나 지우는 방법으로 로그를 주기적으로
    순활할 필요가 있다. 아파치는 파일을 열고있는 동안에는 계속
    이전 로그파일에 쓰기때문에 서버가 실행중일때 로그를 순환할
    수 없다. 대신 로그파일을 옮기거나 지운후 서버를 <a href="stopping.html">재시작</a>하여, 로그파일을 새로 열어야
    한다.</p>

    <p><em>점잖은</em> 재시작을 사용하면 서버는 클라이언트와
    기존의 혹은 대기된 연결을 잃지않고 새 로그파일을 열 수 있다.
    그러나 이를 위해 서버는 오래된 요청의 서비스를 끝내는 동안
    이전 로그파일을 계속 사용해야 한다. 그러므로 재시작한후
    로그파일을 처리하기 전에 얼마간 기다릴 필요가 있다. 일반적으로
    다음과 같이 로그를 순환하고, 디스크공간을 절약하기위해 이전
    로그를 압축한다:</p>

    <div class="example"><p><code>
      mv access_log access_log.old<br />
      mv error_log error_log.old<br />
      apachectl graceful<br />
      sleep 600<br />
      gzip access_log.old error_log.old
    </code></p></div>

    <p>로그를 순환하는 다른 방법은 다음 절에서 설명할 <a href="#piped">파이프 로그</a>를 사용하는 것이다.</p>
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="piped" id="piped">로그를 파이프로 보내기</a></h2>
    

    <p>아파치 웹서버는 오류 로그와 접근 로그를 파일에 직접
    쓰지않고 파이프를 통해 다른 프로세스로 보낼 수 있다. 이
    기능을 사용하면 서버에 코드를 추가하지않고도 매우 유연하게
    로그를 처리할 수 있다. 로그를 파이프에 쓰기위해 파일명
    자리에 파이프문자 "<code>|</code>"와 뒤에 표준입력으로
    로그 항목을 읽을 실행파일명을 적으면 된다. 아파치는 서버가
    시작할때 파이프로 연결할 로그 프로세스를 시작하고, 서버가
    실행되는 동안 프로세스가 죽으면 다시 시작한다. (이 마지막
    기능때문에 우리는 이 방법을 "믿을 수 있는 파이프 로그"라고
    부른다.)</p>

    <p>파이프로 연결된 로그 프로세스는 부모 아파치 httpd 프로세스가
    띄우고, 프로세스의 userid도 같다. 즉, 파이프로 연결된 로그
    프로그램은 보통 root로 실행된다. 그러므로 프로그램을 간단하고
    안전하게 만드는 것이 매우 중요하다.</p>

    <p>파이프로 부르는 전체 명령어를 따옴표로 묶음을 명심하라.
    이 예는 접근 로그에 대한 것이지만, 오류 로그도 마찬가지다.</p>

    <p>서버를 재시작하지않고 로그를 순환할 수 있는 것이 파이프
    로그를 사용하는 중요한 이유다. 아파치 웹서버는 이를 위해
    <a href="programs/rotatelogs.html">rotatelogs</a>라는 간단한
    프로그램을 포함한다. 예를 들어 24시간마다 로그를 순환한다면:</p>

    <div class="example"><p><code>
      CustomLog "|/usr/local/apache/bin/rotatelogs
      /var/log/access_log 86400" common
    </code></p></div>

    <p>다른 사이트에 <a href="http://www.cronolog.org/">cronolog</a>라는 비슷하지만
    훨씬 더 유연한 로그 순환 프로그램이 있다.</p>

    <p>조건부 로그와 같이 파이프 로그는 매우 강력한 도구지만,
    나중에 처리하는 등의 더 간단한 방법이 가능한 경우 사용해서는
    안된다.</p>
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="virtualhost" id="virtualhost">가상호스트</a></h2>
    

    <p>많은 <a href="vhosts/">가상호스트</a>가 있는 서버를
    운영할때 여러가지 방법으로 로그파일을 다룰 수 있다. 먼저,
    호스트가 한개인 서버와 같이 로그를 사용할 수 있다. <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> 섹션이
    아닌 주서버 설정에 로그 지시어를 두면 모든 요청이 같은 접근
    로그와 오류 로그로 기록된다. 이 방법은 가상호스트별로 쉽게
    통계처리를 할 수 없다.</p>

    <p><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
    섹션 안에 <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
    <code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code> 지시어를
    사용하면 해당 가상호스트에 대한 요청과 오류만이 지정된
    파일에 기록된다. 로그 지시어가 없는 다른 가상호스트는 계속
    주서버 로그에 로그를 기록한다. 이 방법은 가상호스트 개수가
    적을 경우 매우 유용하지만, 호스트 수가 많다면 관리하기
    힘들어진다. 또, <a href="vhosts/fd-limits.html">파일기술자가
    부족한</a> 문제가 자주 발생한다.</p>

    <p>접근 로그의 경우 매우 좋은 해결책이 있다. 로그 형식문자열에
    가상호스트에 대한 정보를 추가하면 모든 호스트가 같은 로그를
    사용하고, 나중에 로그를 가상호스트별로 나눌 수 있다. 예를
    들어, 다음 지시어를 봐라.</p>

    <div class="example"><p><code>
      LogFormat "%v %l %u %t \"%r\" %&gt;s %b"
      comonvhost<br />
      CustomLog logs/access_log comonvhost
    </code></p></div>

    <p><code>%v</code>는 요청을 서비스하는 가상호스트 이름을
    기록한다. 나중에 <a href="programs/other.html">split-logfile</a>
    같은 프로그램으로 접근 로그를 가상호스별로 나눌 수 있다.</p>
  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="other" id="other">다른 로그파일</a></h2>
    

    <table class="related"><tr><th>관련된 모듈</th><th>관련된 지시어</th></tr><tr><td><ul><li><code class="module"><a href="./mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="./mod/mod_rewrite.html">mod_rewrite</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewritelog">RewriteLog</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptlog">ScriptLog</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptlogbuffer">ScriptLogBuffer</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptloglength">ScriptLogLength</a></code></li></ul></td></tr></table>

    <h3><a name="pidfile" id="pidfile">PID 파일</a></h3>
      

      <p>아파치 웹서버는 시작할때 <code>logs/httpd.pid</code>
      파일에 부모 httpd 프로세스의 process id를 저장한다. 이
      파일명은 <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code>
      지시어로 변경할 수 있다. process-id는 관리자가 부모 프로세스에
      시그널을 보내 서버를 재시작하거나 죽일때 사용한다.
      윈도우즈에서는 대신 -k 명령행옵션을 사용한다. 더 자세한
      정보는 <a href="stopping.html">중단과 재시작</a> 페이지를
      참고하라.</p>
    

    <h3><a name="scriptlog" id="scriptlog">스크립트 로그</a></h3>
      

      <p>디버깅을 돕기위해 <code class="directive"><a href="./mod/mod_cgi.html#scriptlog">ScriptLog</a></code> 지시어를 사용하여
      CGI 스크립트의 입력과 출력을 기록할 수 있다. 이 지시어는
      오직 테스트용으로만 사용해야 한다. 실제 사용하는 서버에서
      사용하면 안된다. 더 자세한 정보는 <a href="mod/mod_cgi.html">mod_cgi</a> 문서를 참고하라.</p>
    

    <h3><a name="rewritelog" id="rewritelog">재작성 로그</a></h3>
      

      <p><a href="mod/mod_rewrite.html">mod_rewrite</a>의 강력하고
      복잡한 기능을 사용한다면 디버깅을 위해 거의 항상 <code class="directive"><a href="./mod/mod_rewrite.html#rewritelog">RewriteLog</a></code>를 사용할 필요가
      있다. 이 로그파일은 재작성 엔진이 어떻게 요청을 변환하는지에
      대해 자세히 알려준다. 자세한 정도는 <code class="directive"><a href="./mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></code> 지시어로
      조절한다.</p>
    
  </div></div>
<div class="bottomlang">
<p><span>가능한 언어: </span><a href="./en/logs.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./fr/logs.html" hreflang="fr" rel="alternate" title="Fran&#231;ais">&nbsp;fr&nbsp;</a> |
<a href="./ja/logs.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/logs.html" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/logs.html" hreflang="tr" rel="alternate" title="T&#252;rk&#231;e">&nbsp;tr&nbsp;</a></p>
</div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/2.4/logs.html';
(function(w, d) {
    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
        d.write('<div id="comments_thread"><\/div>');
        var s = d.createElement('script');
        s.type = 'text/javascript';
        s.async = true;
        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
    }
    else { 
        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
    }
})(window, document);
//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="./mod/">모듈</a> | <a href="./mod/directives.html">지시어들</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">용어</a> | <a href="./sitemap.html">사이트맵</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
    prettyPrint();
}
//--><!]]></script>
</body></html>