Difference between revisions of "CLI - Log"

Line 25: Line 25:
 
</pre>
 
</pre>
  
=== Basic Command ===
+
==== Basic Command ====
 
<pre>
 
<pre>
 
LYSH@MyHostName# show log {name} [-h] [-n NUMBER] [-w] [keyword]
 
LYSH@MyHostName# show log {name} [-h] [-n NUMBER] [-w] [keyword]
 +
optional arguments:
 +
  -h, --help                      show this help message and exit
 +
  -n [NUMBER], --number [NUMBER]  enter 0 to show all logs, and enter a value greater than 0 to show as much as the value entered
 +
  -w, --watch                    show the log or setup status in real time
 +
</pre>
 +
 +
==== Display logs ====
 +
<pre>
 +
LYSH@MyHostName# show log apache2 // Display all apache2 logs
 +
LYSH@MyHostName# show log radius // Display all radius logs
 +
</pre>
 +
 +
==== Display last n logs ====
 +
<pre>
 +
LYSH@MyHostName# show log apache2 -n 10 // Display only the last 10 apache2 logs
 +
LYSH@MyHostName# show log radius -n 10 // Display only the last 10 radius logs
 
</pre>
 
</pre>
  
=== After Commands ===
+
==== Display last n logs with keyword ====
추가 옵션을 통해 실시간으로 확인할 수 있는 <code>--watch</code>옵션, 로그 출력 갯수<code>--number</code>, 특정 단어<code>[keyword]</code>를 지정할 수 있습니다. 특정 키워드로 검색할 경우 <code>|</code>, <code>&</code>를 통해서 여러가지 키워드를 and, or로 검색할 수 있습니다.
 
 
<pre>
 
<pre>
usage: show log {service name} [-h] [-n NUMBER] [-w] [keyword]
+
LYSH@MyHostName# show log apache2 -n 10 request // Display only the last 10 apache2 logs filtered by "request"
 +
LYSH@MyHostName# show log radius -n 10 accept // Display only the last 10 radius logs filtered by "request"
 +
</pre>
  
positional arguments:
+
==== Display logs in real-time ====
  [keyword]                      keyword to display
+
<pre>
 +
LYSH@MyHostName# show log apache2 -w // Display the apache2 logs in real-time
 +
LYSH@MyHostName# show log radius -w // Display the radius logs in real-time
 +
</pre>
  
optional arguments:
+
==== Display logs in real-time with keyword ====
  -h, --help                      show this help message and exit
+
<pre>
  -n [NUMBER], --number [NUMBER]  all(0) or ther count (0 < n) of most recent syslog
+
LYSH@MyHostName# show log apache2 -w request // Display the apache2 logs filtered by "request" in real-time
  -w, --watch                    realtime watch
+
LYSH@MyHostName# show log radius -w accept // Display the radius logs filtered by "accept" in real-time
 
</pre>
 
</pre>
* <code>LYSH@MyHostName# show log apache2 -w</code> apache2의 log가 tail -f 모드로 log를 출력합니다.
 
* <code>LYSH@MyHostName# show log lsyslog [something]</code> lsyslog의 log에서 [something]을 포함한 라인을 출력합니다.
 
* <code>LYSH@MyHostName# show log mysqlerror "some|thing"</code> mysqlerror의 log에서 some 또는 thing을 포함한 라인을 출력합니다.
 
* <code>LYSH@MyHostName# show log dhcpv4 "some&thing"</code> dhcpv4의 log에서 some과 thing을 포함한 라인을 출력합니다.
 
* <code>LYSH@MyHostName# show log failover "some&thing|something" -n 2</code> failover의 log에서 some과 thing을 포함하거나 something을 포함한 라인을 2개만 출력합니다.
 
  
2개 이상의 키워드를 검색할 경우 반드시 쌍따옴표<code>"keyword"</code>를 포함하여 입력해야합니다.
+
==== keyword ====
 +
The <code>&</code> is the Logical AND operator and the <code>|</code> is the Logical OR operator.
 +
<pre>
 +
LYSH@MyHostName# show log request&reply // Display the apache2 logs having both "request" and "reply"
 +
LYSH@MyHostName# show log request|reply // Display the apache2 logs having either "request" or "reply"
 +
</pre>

Revision as of 17:46, 16 April 2021

You can see various logs using the show log command.

LYSH@MyHostName# show log -h
usage: show log [-h] {apache2,dhcpv4,dhcpv6,failover,logexp,lsyslog,mysqlerror,mysqlslow,radius,smgr,startup,syslog,update} ...

positional arguments:
    apache2                             Show apache2 log
    dhcpv4                              Show dhcpv4 log
    dhcpv6                              Show dhcpv6 log
    failover                            Show failover log
    logexp                              Show logexp log
    lsyslog                             Show product syslog log
    mysqlerror                          Show mysql error log
    mysqlslow                           Show mysql slow query log
    radius                              Show radius log
    smgr                                Show smgr log
    startup                             Show startup log
    syslog                              Show syslog log
    update                              Show update log

optional arguments:
  -h, --help                            show this help message and exit

Basic Command

LYSH@MyHostName# show log {name} [-h] [-n NUMBER] [-w] [keyword]
optional arguments:
  -h, --help                      show this help message and exit
  -n [NUMBER], --number [NUMBER]  enter 0 to show all logs, and enter a value greater than 0 to show as much as the value entered
  -w, --watch                     show the log or setup status in real time

Display logs

LYSH@MyHostName# show log apache2		// Display all apache2 logs
LYSH@MyHostName# show log radius		// Display all radius logs

Display last n logs

LYSH@MyHostName# show log apache2 -n 10		// Display only the last 10 apache2 logs
LYSH@MyHostName# show log radius -n 10		// Display only the last 10 radius logs

Display last n logs with keyword

LYSH@MyHostName# show log apache2 -n 10	request	// Display only the last 10 apache2 logs filtered by "request" 
LYSH@MyHostName# show log radius -n 10	accept	// Display only the last 10 radius logs filtered by "request" 

Display logs in real-time

LYSH@MyHostName# show log apache2 -w		// Display the apache2 logs in real-time
LYSH@MyHostName# show log radius -w		// Display the radius logs in real-time

Display logs in real-time with keyword

LYSH@MyHostName# show log apache2 -w request	// Display the apache2 logs filtered by "request" in real-time
LYSH@MyHostName# show log radius -w accept	// Display the radius logs filtered by "accept" in real-time

keyword

The & is the Logical AND operator and the | is the Logical OR operator.

LYSH@MyHostName# show log request&reply		// Display the apache2 logs having both "request" and "reply"
LYSH@MyHostName# show log request|reply		// Display the apache2 logs having either "request" or "reply"