WEBVTT

00:03.100 --> 00:07.720
And Gen X uses log files to record various operational details.

00:08.290 --> 00:14.140
These logs are useful for monitoring normal operations and tracking down issues if a problem occurs.

00:14.680 --> 00:20.480
Let's start by taking a look inside the main configuration file and an ex-cons inside this file.

00:20.500 --> 00:26.260
If we search for log, we can find two entries access, underscore, log, and error underscore log.

00:26.800 --> 00:32.350
The access log is where Engine X records each request that it serves, whether the request is served

00:32.350 --> 00:34.000
successfully or not.

00:34.600 --> 00:39.970
Each request can be recorded along with various metadata, like the date and time of the request, the

00:39.970 --> 00:44.110
IP address of the requester, and the path to the document that was served.

00:44.760 --> 00:50.920
Engine X uses the error log to store operational details ranging from debug information to warnings

00:50.920 --> 00:52.270
and critical errors.

00:52.870 --> 00:59.170
If Engine X is set up to serve multiple sites but the default logging configuration is used, then all

00:59.170 --> 01:02.590
the requests for all the sites will be written to the same logs.

01:03.160 --> 01:08.860
This can become an issue if, for example, you need to find the access logs for one specific site.

01:09.450 --> 01:14.250
Fortunately, logging can be configured in the server and location contexts.

01:14.820 --> 01:17.460
Let's set up logging for our demo site.

01:18.050 --> 01:21.110
First, let's edit our configuration file.

01:21.620 --> 01:27.740
Now we can add access logs in error log specifically for this virtual host with the access log and error

01:27.740 --> 01:30.320
log directives followed by the paths to the file.

01:30.320 --> 01:33.530
And I like to add these close to the top of the configuration.

01:34.100 --> 01:40.130
And just for demonstration purposes, let's also add access and error logs in the images location.

01:40.670 --> 01:44.630
Now let's save this test our configuration and reload it.

01:45.170 --> 01:46.190
Bummer.

01:46.890 --> 01:51.870
It looks like we forgot to add semicolons after some of the statements that we just added.

01:52.410 --> 01:53.850
Let's fix that.

01:54.510 --> 01:56.340
Okay, one more time.

01:56.820 --> 01:59.310
Let's test this configuration.

01:59.790 --> 02:00.710
Looks good.

02:00.720 --> 02:02.520
So now let's reload it.

02:03.030 --> 02:07.740
If we change to the log directory, we can see that our new log files have been created.

02:07.740 --> 02:10.710
But they're empty because no requests have come through.

02:11.280 --> 02:16.470
Instead of loading the page in the browser, we can use a for loop to curl local host ten times while

02:16.470 --> 02:19.320
sending the output to slash dev slash null.

02:19.920 --> 02:25.560
And now if we look inside the access log for our site, we can see ten records that correspond to the

02:25.560 --> 02:27.360
ten curls that we just made.

02:27.870 --> 02:34.290
We can do the same thing for the images location because we're requesting a directory location.

02:34.290 --> 02:37.170
We need to add a trailing slash in this case.

02:37.800 --> 02:43.770
And now if we check the contents of the images access log, we can see the logs for each request.

02:44.370 --> 02:49.800
Seeing the content in the access files for both of these locations lets us know that our custom logging

02:49.800 --> 02:51.960
directives are configured properly.

02:52.590 --> 02:57.480
As you're working with Gen X, there may come a time when things just aren't working the way you think

02:57.480 --> 02:58.320
they should.

02:58.860 --> 03:04.020
Here are a few tools and ideas you can use to troubleshoot and resolve some of the typical problems

03:04.020 --> 03:05.160
you might encounter.

03:05.730 --> 03:10.500
We can catch configuration errors with Engine x TX after making changes.

03:11.150 --> 03:17.180
If there's a typo in your configuration file and Gen X TX will identify the error and the file it occurs

03:17.180 --> 03:18.770
in along with the line number.

03:19.420 --> 03:24.910
In this example, I've misspelled the server keyword online, one of the configuration file.

03:25.420 --> 03:27.340
This is an easy fix.

03:27.970 --> 03:31.930
Also check for typos in your route and server name directives.

03:32.470 --> 03:37.480
In some cases, these typos won't be flagged when you test the configuration.

03:38.020 --> 03:47.650
In this example, TM one should really be HTML and w w w dot example.com should be w w w dot example.com.

03:48.220 --> 03:50.620
Keep an eye out for illusive errors like these.

03:50.620 --> 03:54.580
But what about problems that occur after you know the configuration is good?

03:55.150 --> 03:59.860
Let's say for instance, you've made some changes to your site, but the changes aren't showing up where

03:59.860 --> 04:01.600
you can't reach your site at all.

04:02.140 --> 04:07.060
The first thing you can do is make sure Engine X is running the system.

04:07.090 --> 04:12.820
CTL status Engine X command give output that confirms whether Engine X is running or not.

04:13.360 --> 04:19.030
Then you might also want to reload the configuration with sys CTL reload engine x.

04:19.630 --> 04:23.710
This command doesn't produce any output if it runs successfully.

04:24.280 --> 04:28.600
So check the site afterward to see if your changes are now being applied.

04:29.140 --> 04:30.010
If engine x.

04:30.010 --> 04:34.660
If up and running but you aren't seeing anything served, you'll want to check that the standard ports

04:34.660 --> 04:37.740
for HTTP and HTTPS traffic are open.

04:37.750 --> 04:40.300
Ports 80 and 443.

04:40.910 --> 04:45.680
You can check the status of these ports using the sub and net stat commands.

04:46.340 --> 04:51.590
Less of which is short for list open files, lists, all the files and network ports that are open on

04:51.590 --> 04:59.330
the system using the ice, which we can check to see if Engine X is listening on ports 80 and 443.

05:00.010 --> 05:06.220
Another way to confirm in Gen X is listening on these ports is with the network status or net stat command.

05:06.760 --> 05:13.420
Net stat gives us information on all of the network connections for the system using the right switches

05:13.420 --> 05:19.480
dash plan and grouping for Engine X, we can also get net stack to give us the idea of the process that's

05:19.480 --> 05:20.740
listening to the port.

05:21.310 --> 05:26.950
If your configuration is good and Engine X is up running and listening on the right ports, but something

05:26.950 --> 05:29.800
is still out of place, it's time to turn to the logs.

05:30.370 --> 05:35.530
You can use the tail command with the f switch to follow the engine X logs as they're being written

05:35.530 --> 05:38.500
to the disk while following the log.

05:38.500 --> 05:43.690
You can try to access various parts of your site and see if the accesses are being recorded.

05:44.330 --> 05:49.640
If they are, you can check for 400 errors which might lead to problems like files not being in the

05:49.640 --> 05:53.000
right place or directories that don't have the correct permissions.

05:53.570 --> 05:55.760
If all else fails, seek help.

05:56.270 --> 06:02.420
You can turn to a search engine or http colon slash slash StackOverflow dot com to research the error

06:02.420 --> 06:03.980
or problem that you're seeing.

06:04.550 --> 06:09.290
Hopefully someone else has encountered the same problem and provided a solution.

06:09.920 --> 06:15.020
Finding solutions to your problems might take a while at first, but as you gain more experience with

06:15.020 --> 06:18.140
Engine X, your troubleshooting will become much more efficient.
