As an experienced website operations expert, I am well aware that log files play a crucial role behind the stable operation of the system.When your AnQiCMS website encounters a program error, the log file is like a clue in the detective's hands, which can help us trace the cause and specific details of the problem.AnQiCMS is an enterprise-level content management system developed based on the Go language, with a simple and efficient logging mechanism. Understanding the storage path and viewing method of the log files is the first step in troubleshooting program errors and ensuring the healthy operation of the website.
Why are log files so important?
Imagine that your AnQiCMS website suddenly cannot be accessed, or some function appears abnormal.Faced with these sudden situations, we cannot rely solely on guesswork.At this time, the log file can provide the most direct and objective evidence.Error and exception information. By analyzing these logs, we can accurately locate the problematic code, incorrect configuration, resource bottlenecks, or other potential faults, and thus solve the problem specifically.
AnQiCMS as an application written in Go language, its log output is usually directed to standard output (stdout) and standard error (stderr).Where these outputs will ultimately converge depends on your specific deployment environment and method.Below, we will detail how to locate and view the log files based on common AnQiCMS deployment scenarios.
Log path under Linux server manual/script deployment environment
On the Linux server, if you are following the official documentation of AnQiCMS (such asinstall.mddescribed throughstart.shScript) for deployment, then the storage path of the log file will usually be very clear.
Officially providedstart.shIn the script, there is a key command line like this:nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
The meaning of this command is to redirect all standard output and standard error of the AnQiCMS program($BINPATH/$BINNAMErepresenting the executable file path and name of AnQiCMS)(2>&1Redirected to the specified path.running.logthe file.nohupCommand ensures that the program continues to run in the background even if you close the terminal.
Therefore, in the directory of your AnQiCMS executable file (which isinstall.mdmentioned$BINPATHFor example/www/wwwroot/anqicms.com/), you will find a file namedrunning.logThe file. This file records all the outputs during the program startup and operation, including normal information and various errors.
exceptrunning.log,start.shThe script may also contain references tocheck.logFile writing. This file is usually used to record the self-check information of the script, such as whether the program is running, etc. Althoughrunning.logit is the main force for troubleshooting program errors, but understandingcheck.logThe existence also helps provide clues even if the program has not started.
How to view these log files:
After finding the log file, you can connect to the Linux server via SSH and use the following command to view the log content:
- View in real time (recommended):
tail -f /www/wwwroot/yourdomain/running.logThis will continue to displayrunning.logThe latest content of the file, which will be refreshed in real-time to the screen when new logs are generated, is very suitable for fault monitoring of running websites. Please/www/wwwroot/yourdomain/Replace with the actual AnQiCMS deployment path. - View all content:
cat /www/wwwroot/yourdomain/running.logThis will print the entirerunning.logcontent of the file to the screen. If the log file is very large, it may scroll the screen. - Page through:
less /www/wwwroot/yourdomain/running.logWhen the log file content is extensive,lessThe command can enable page through and supports search functionality, making it convenient for you to browse historical logs.
Log path under Docker container deployment environment
If you choose to use Docker (for example, through 1Panel or aaPanel deployment), AnQiCMS's log management method will be different, but still clear.
The design philosophy of Docker containers is to allow applications to output logs to their standard output (stdout) and standard error (stderr), while the Docker daemon captures these outputs.
How to view Docker container logs:
Use the Docker command line:First, you need to know the name or ID of the AnQiCMS container. You can find it by
docker psCommand to view the list of running containers. After finding the AnQiCMS container, the name is usually similar toanqicmsOr you can customize the name when deploying. Then, use the following command to view container logs:docker logs [container_name_or_id]For example:docker logs anqicmsIf you want to view it in real time, you can add
-fparameters:docker logs -f anqicmsPass through the 1Panel or aaPanel panel:These graphical management panels usually provide convenient container log viewing functions.
- Log in to your 1Panel or aaPanel dashboard.
- Navigate to the 'Container' or 'Docker' management interface.
- Find the AnQiCMS container you have deployed, click to view the details or log options.
- The panel displays the container's real-time logs or historical logs in a friendly interface, and usually provides search, filter, and download functions.
Log path under local test environment of Windows/MacOS
When developing and testing locally on Windows or MacOS systems, the situation is usually simpler:
- Run the executable file directly:If you are double-clicking directly
anqicms.exe(Windows) oranqicmsTo run the program on (MacOS), any standard output and errors will usually be displayed directly in the command line window (Console).Please do not close the window immediately after the program runs so that you can observe the log information. - Simulate Linux script deployment:Although not common, if you use something similar on Windows or MacOS,
start.shThe script (e.g., using WSL or a terminal emulator) to start AnQiCMS, then the log file will also be generated according to the redirection rules of the script, in the directory of the executable file, which is usually alsorunning.log.
What should you pay attention to when viewing log content?
No matter where the log file is stored, you should pay special attention to the following keywords when viewing:
ERRORorerrorFATALorfatalPANICorpanicWARNorwarningFailedorfailedSQL(May indicate database connection or operation issues)connection refused(commonly occurs due to database or port connection failure)- Timestamp: This can help you determine the specific time when the problem occurred, narrowing down the troubleshooting scope.
- Stack Trace: This is usually the code execution path printed when the program crashes, which can accurately point to the source of the problem.
By systematically searching and analyzing these logs, you will be able to diagnose the program errors encountered by AnQiCMS more efficiently and accurately, thus quickly restoring the normal operation of the website.
Frequently Asked Questions (FAQ)
- Ask: AnQiCMS program cannot start,
running.logThere is nothing in the file, how should I investigate? Answer:Ifrunning.logEmpty, usually means that the program has not even started successfully to the stage where it can write logs, or there is a problem with the log redirection configuration. In this case, you need to check several aspects:- Executable file permissions:Ensure that the AnQiCMS executable file (such as
anqicms) has execution permissions. On Linux, you can usechmod +x anqicmscommand to assign permissions. - The problem with starting the script:Check
start.shIs the syntax of the script incorrect, or is the defined$BINPATHand$BINNAMEVariable pointing to the correct file. - Port occupied:AnQiCMS uses the default port 8001. If this port is occupied by another program, AnQiCMS will not start. You can use
lsof -i:8001(Linux) or check the Task Manager (Windows) to check for port usage. If the port is occupied, you may need toconfig.jsonChange the running port of AnQiCMS and update your Nginx/Apache proxy configuration accordingly. - System environment dependencies:Check your
- Executable file permissions:Ensure that the AnQiCMS executable file (such as