Skip to main content
dbabic
Staff
Staff
Apr 10, 2017 2:15 PM UTC

Technical Tip: Displaying logs via FortiGate's CLI

  • Oct 9, 2026 6:24 AM UTC
  • 0 replies
  • 303766 views
  • Translate All

Description

 

This article describes that a FortiGate can display logs via both the GUI and the CLI and how to display logs through the CLI.

 

Scope

 

FortiGate.

 

Solution

 

To display log records in the CLI, use the following command (for VDOM-enabled FortiGates, this will be run in non-global VDOMs):

 

execute log display

 

Note:

By default, no filters are applied to the above command, and so log records of all sub-types will be printed to the CLI. To filter this output to show specific log messages or categories of logs, use the execute log filter series of commands. This allows administrators to control which logs will be displayed and how many can be viewed at a time (up to 1000 lines of log messages per batch).

 

Before applying a new filter, it is recommended to check the current filter settings using execute log filter dump. If necessary, the filter can be reset using the command execute log filter reset:

 

FortiGate # execute log filter reset

FortiGate # execute log filter dump
category: traffic
device: disk
start-line: 1
view-lines: 10
max-checklines: 0
HA member:
log search mode: on-demand
pre-fetch-pages: 2
Oftp search string:

 

The following is an overview of the available options in the execute log filter command family:

 

FortiGate # execute log filter ?
category             Category.
device               Device to get log from.
dump                 Dump current filter settings.
field                Filter by field.
free-style           Filter by free-style expression.
ha-member            HA member.
local-search-mode    local log search mode
max-checklines       Maximum number of lines to check.
pre-fetch-pages      Number of pages to check in advance under on-demand log search mode.
reset                Reset filter.
start-line           Start line to display.
view-lines           Lines per view.

 

Note:

The field option supports further customization, such as using the 'not' keyword to reverse the filter, or '-' to specify ranges. Hit Enter when the command is incomplete to see the available options. For example:

 

FortiGate # execute log filter field date ?
You can specify from 1 to 5 values
value1 [value2 ... value5] [not]
Use not to reverse the condition.
Each value can be a individual value or a value range.
For value range, "-" is used to separate two values.
Command fail. Return code -50

 

Applying log display filters - device:

The first step is to specify the logging device on the FortiGate that should be checked and displayed:

 

execute log filter device <device>

 

From FortiOS 6.2 and later, the following logging devices are available to be searched (assuming the device has them enabled/configured):

 

FGT81F_PJ_3960(Primary) (root) # execute log filter device ?
Available devices:
 0: memory
 1: disk
 2: fortianalyzer
 3: fortianalyzer-cloud
 4: forticloud

 

For example, running the command execute log filter device 0 will result in the FortiGate searching and displaying logs stored in memory.

 

Note that the 'fortianalyzer-cloud' option was not available in FortiOS 6.0 and earlier, which resulted in the following options list instead:

 

Available devices:
 0: memory
 1: disk
 2: fortianalyzer
 3: forticloud

 

Applying log display filters - category:

The next step is to choose the category of logs to display:

 

execute log filter category <category>

 

Generally speaking, each new FortiOS major/minor version (8.0, 7.6, 7.4, etc.) will retain support for the existing category ID numbers while also adding new logging categories. The following are the available categories and IDs available for filtering, as well as which FortiOS versions support them:

 

FortiOS version support:

Added/available category filters:

Notes:

FortiOS 5.4+

 0: traffic
 1: event
 2: utm-virus
 3: utm-webfilter
 4: utm-ips
 5: utm-emailfilter
 7: anomaly
 8: voip
 9: utm-dlp
10: utm-app-ctrl
12: utm-waf

FortiOS 5.6+

15: dns

FortiOS 6.0+

16: utm-ssh

FortiOS 6.0 and later renamed the following categories:

  • '7: anomaly' renamed to '7: utm-anomaly'

  • '8: voip' renamed to '8: utm-voip'

FortiOS 6.2+

17: utm-ssl
18: utm-cifs
19: utm-file-filter

FortiOS 6.2 and later renamed '15: dns' to '15: utm-dns'

FortiOS 6.4+

20: utm-icap

FortiOS 6.4.2 and later removed '18: utm-cifs' since CIFS profiles were moved into Profile-Protocol Options profiles (Change #627100)

FortiOS 7.0+

22: utm-sctp-filter

FortiOS 7.2+

23: forti-switch

FortiOS 7.4+

24: utm-virtual-patch
25: utm-casb

FortiOS 7.6+

26: debug

FortiOS 8.0+

27: utm-llm

 

Note:

The above filters apply to log searching/displaying logs already stored in the logging device. It is also possible to apply filters on the FortiGate to determine which logs are stored/recorded in the first place (useful for reducing overall logging volume/rates if certain categories are unnecessary). For more information on preventing certain log types from being captured, refer to the following documentation:

 

Additional filters and examples:

For example, by using the following log filters, FortiGate will display all utm-webfilter logs with the destination IP address 40.85.78.63:

 

FortiGate # execute log filter category 3        
FortiGate # execute log filter field dstip 40.85.78.63 
FortiGate # execute log display
1 logs found.
1 logs returned.

1: date=2019-09-14 time=14:52:36 logid="0317013312" type="utm" subtype="webfilter" eventtype="ftgd_allow" level="notice" vd="root" eventtime=1568465556531146383 tz="+0200" policyid=1 sessionid=3190297 srcip=172.16.190.216 srcport=10806 srcintf="port3" srcintfrole="undefined" dstip=40.85.78.63 dstport=443 dstintf="port1" dstintfrole="undefined" proto=6 service="HTTPS" hostname="wdcp.microsoft.com" profile="monitor-all" action="passthrough" reqtype="direct" url="/" sentbyte=197 rcvdbyte=3787 direction="outgoing" msg="URL belongs to an allowed category in policy" method="domain" cat=52 catdesc="Information Technology"

 

In addition to specifying category/device/etc. log filters, it is also possible to utilize the free-style filters with execute log filter free-style <BPF_style_filter>. For example, by using the following log filters, FortiGate will display all utm-webfilter logs with destination IP address 40.85.78.63 that are not from September 13, 2019:

 

execute log filter free-style "(date 2019-09-13 not) and (dstip 40.85.78.63)" 
execute log display
1 logs found.
1 logs returned.


1: date=2019-09-14 time=14:52:36 logid="0317013312" type="utm" subtype="webfilter" eventtype="ftgd_allow" level="notice" vd="root" eventtime=1568465556531146383 tz="+0200" policyid=1 sessionid=3190297 srcip=172.16.190.216 srcport=10806 srcintf="port3" srcintfrole="undefined" dstip=40.85.78.63 dstport=443 dstintf="port1" dstintfrole="undefined" proto=6 service="HTTPS" hostname="wdcp.microsoft.com" profile="monitor-all" action="passthrough" reqtype="direct" url="/" sentbyte=197 rcvdbyte=3787 direction="outgoing" msg="URL belongs to an allowed category in policy" method="domain" cat=52 catdesc="Information Technology"

 

Other examples of using the free-style log filter:

 

execute log filter free-style "srcip 172.16.1.1"
execute log filter free-style "(srcip 172.16.1.1) or (dstip 172.16.1.2)"
execute log filter free-style "(srcip 172.16.1.1) and (dstip 172.16.1.2)"
execute log filter free-style "((srcip 172.16.1.1) or (dstip 172.16.1.2)) and (dstport 80 443 50-60)"

 

The following example filters will provide the output of all the event logs:

 

execute log filter category 1
execute log filter view-lines <#_of_logs_to_display>
execute log display

 

To check the specific event logs such as system event logs, apply further filters as below:

 

execute log filter category 1
execute log filter field subtype system
execute log filter view-lines <#_of_logs_to_display>
execute log display

 

To check two subtypes - for example, 'system' and 'ha' - apply the following filter below: 

 

execute log filter category 1
execute log filter field subtype system ha
execute log filter view-lines <#_of_logs_to_display>
execute log display

 

Note:

By default, the FortiGate CLI will only output batches of 10 logs each time the execute log display command is run (i.e. logs are paged through with each run). To view more log entries per run, increase the number of log entries displayed at once using the following command:

 

execute log filter view-lines <5-1000, default = 10>

 

Continue running the 'execute log display' command repeatedly to scroll through the pages until reaching the last entry as desired.

 

Finally, it is also possible to perform additional tasks with the logs:

 

FortiGate # execute log ?
backup                 backup
delete                 Delete local logs of one category.
delete-all             Delete all local logs and recreate report database.
detail                 Display utm log entries for a particular traffic log.
display                Display filtered log entries.
filter                 filter
flush-cache            Write disk log cache of current category to disk in compressed format.
flush-cache-all        Write disk log cache of all categories to disk in compressed format.
fortianalyzer          fortianalyzer
fortianalyzer-cloud    fortianalyzer-cloud
fortianalyzer2         fortianalyzer2
fortianalyzer3         fortianalyzer3
list                   List current and rolled log files info.
raw-backup             raw-backup
roll                   Roll log files now.

 

Related articles:

Technical Tip: Using filters to send only specific logs to the remote logging solution

Technical Tip: Using a CLI command to check the firewall policy creation date and time

Risk and Resilience in the Age of AI. An OT Thought Leadership Summit for Houston's Critical Infrastructure Leaders. Date: Thursday, December 3, 2026. Time: 8:30 am - 1:30 pm (CT). Location: The Westin Houston, Memorial City | 945 Gessner Road, Houston, TX 77024