<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1470134809057_5224">Hello Francis,</div><div id="yui_3_16_0_ym19_1_1470134809057_5319"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5318">Thank you very much, it works better, however it works only for access_log for some reason</div><div id="yui_3_16_0_ym19_1_1470134809057_5322"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5323" dir="ltr">nginx.conf</div><div id="yui_3_16_0_ym19_1_1470134809057_5324" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5431" dir="ltr">http {</div><div id="yui_3_16_0_ym19_1_1470134809057_5432" dir="ltr">log_format main '$remote_addr forwarded for $http_x_real_ip -
$remote_user [$time_local] ' '"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';</div><div id="yui_3_16_0_ym19_1_1470134809057_5527" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5528" dir="ltr">sites-available/default</div><div dir="ltr">server {</div><div id="yui_3_16_0_ym19_1_1470134809057_5644" dir="ltr">...</div><div id="yui_3_16_0_ym19_1_1470134809057_5645" dir="ltr">access_log /var/log/nginx/default.access.log main;</div><div id="yui_3_16_0_ym19_1_1470134809057_5656" dir="ltr">error_log /var/log/nginx/default.error.log;</div><div dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5701" dir="ltr">With</div><div dir="ltr">error_log /var/log/nginx/default.error.log main;</div><div id="yui_3_16_0_ym19_1_1470134809057_5839" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5702" dir="ltr">Nginx fails to start</div><div id="yui_3_16_0_ym19_1_1470134809057_5777" dir="ltr"># nginx<br id="yui_3_16_0_ym19_1_1470134809057_5789">nginx: [emerg] invalid log level "main" in /etc/nginx/sites-enabled/default:13</div><div id="yui_3_16_0_ym19_1_1470134809057_5840" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1470134809057_5841" dir="ltr">The documentation only talks about access_log. Do you think it's normal ?<br></div><div id="yui_3_16_0_ym19_1_1470134809057_5325"><span></span></div> <div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font face="Arial" size="2"> Le Mardi 2 août 2016 10h00, Francis Daly <francis@daoine.org> a écrit :<br></font></div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <br><br> <div class="y_msg_container">On Mon, Aug 01, 2016 at 11:25:46PM +0000, Mik J wrote:<br clear="none"><br clear="none">Hi there,<br clear="none"><br clear="none">> nginx: [emerg] unknown log format "main" in /etc/nginx/sites-enabled/default:8<br clear="none">> <br clear="none">> in nginx.conf I havehttp {<br clear="none">> include mime.types;<br clear="none">> include /etc/nginx/sites-enabled/*;<br clear="none">> include /etc/nginx/conf.d/*;<br clear="none">> default_type application/octet-stream;<br clear="none">> index index.html index.htm;<br clear="none">> log_format main '$remote_addr forwarded for $http_x_real_ip - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';...<br clear="none"><br clear="none">Look at the order of config lines there.<br clear="none"><br clear="none">You have, effectively,<br clear="none"><br clear="none"> http {<br clear="none"> server {<br clear="none"> access_log /tmp/out.log main;<br clear="none"> }<br clear="none"> log_format main '$remote_addr $request';<br clear="none"> }<br clear="none"><br clear="none">and nginx complains that "main" is not defined at the "access_log" line.<br clear="none"><br clear="none">> i think I did things good but it's like the line in nginx.conf is not taken into account<br clear="none">> Do you know why ?<br clear="none"><br clear="none">If you put the "log_format" line before the "server" block (i.e., before<br clear="none">the appropriate "include" line), nginx will probably be happier.<br clear="none"><br clear="none">Arguably, since "log_format" is at http-level only, and you can't repeat<br clear="none">"name", nginx *could* be able to handle things out of order. But right<br clear="none">now it doesn't, so the quick fix is to re-order things yourself.<br clear="none"><br clear="none">Cheers,<div class="yqt7845374950" id="yqtfd59656"><br clear="none"><br clear="none"> f</div><br clear="none">-- <br clear="none">Francis Daly <a shape="rect" ymailto="mailto:francis@daoine.org" href="mailto:francis@daoine.org">francis@daoine.org</a><br clear="none"><br clear="none">_______________________________________________<br clear="none">nginx mailing list<br clear="none"><a shape="rect" ymailto="mailto:nginx@nginx.org" href="mailto:nginx@nginx.org">nginx@nginx.org</a><br clear="none"><a shape="rect" href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br><br></div> </blockquote> </div> </div> </div></div></body></html>