diff --git a/inc/lektor/common.h b/inc/lektor/common.h
index 00f213adbb5f7e3748f6376be03d6564100a1d10..3bfe7e42ae06cf81ad29e1b0a2edfaf0c1ce9798 100644
--- a/inc/lektor/common.h
+++ b/inc/lektor/common.h
@@ -89,12 +89,13 @@ enum log_level {
     __LAST_UNUSED_LOG_LEVEL,    /* Usefull to enable all by default */
 };
 extern enum log_level __log_level;
-void __lkt_log(enum log_level, const char *section, const char *func, uint64_t line, const char *format, ...);
-#define LOG_DEBUG(section, ...) __lkt_log(DEBUG, section, __func__, __LINE__, __VA_ARGS__)
-#define LOG_INFO( section, ...) __lkt_log(INFO,  section, __func__, __LINE__, __VA_ARGS__)
-#define LOG_WARN( section, ...) __lkt_log(WARN,  section, __func__, __LINE__, __VA_ARGS__)
-#define LOG_ERROR(section, ...) __lkt_log(ERROR, section, __func__, __LINE__, __VA_ARGS__)
-#define LOG_FATAL(...)          { __lkt_log(ERROR, "FATAL", __func__, __LINE__, __VA_ARGS__); exit(1); }
+void __lkt_log(enum log_level, const char *section, const char *func, const char *file,
+               uint64_t line, const char *format, ...);
+#define LOG_DEBUG(sec, ...) __lkt_log(DEBUG, sec, __func__, __FILE__, __LINE__, __VA_ARGS__)
+#define LOG_INFO( sec, ...) __lkt_log(INFO,  sec, __func__, __FILE__, __LINE__, __VA_ARGS__)
+#define LOG_WARN( sec, ...) __lkt_log(WARN,  sec, __func__, __FILE__, __LINE__, __VA_ARGS__)
+#define LOG_ERROR(sec, ...) __lkt_log(ERROR, sec, __func__, __FILE__, __LINE__, __VA_ARGS__)
+#define LOG_FATAL(...) { LOG_ERROR("FATAL", __VA_ARGS__); exit(1); }
 
 #define SELF_EXECUTABLE_LINUX       "/proc/self/exe"
 #define SELF_EXECUTABLE_FREEBSD     "/proc/curproc/file"
diff --git a/src/base/common.c b/src/base/common.c
index c297695b9827bdae4dbddc3b539711f69f755c4e..3026d0fd205f2e8285445a2a2a0cd8a18d189ca5 100644
--- a/src/base/common.c
+++ b/src/base/common.c
@@ -53,8 +53,8 @@ __set_assert(void)
 enum log_level __log_level = __LAST_UNUSED_LOG_LEVEL; /* All by default */
 
 void
-__lkt_log(enum log_level level, const char *section, const char *func, uint64_t line_number,
-          const char *format, ...)
+__lkt_log(enum log_level level, const char *section, const char *func, const char *file,
+          uint64_t line_number, const char *format, ...)
 {
     char line[LKT_MESSAGE_MAX];
     va_list ap;
@@ -67,13 +67,19 @@ __lkt_log(enum log_level level, const char *section, const char *func, uint64_t
         sec  = timeval->tm_sec;
     }
 
+    size_t skip_dir = 0;
+    do {
+        file += skip_dir + 1;
+        skip_dir = strcspn(file, "/");
+    } while (file[skip_dir] && file[skip_dir + 1]);
+
     if (level > __log_level)
         return;
 
-    safe_snprintf(line, LKT_MESSAGE_MAX, " %c [%02d:%02d:%02d] %-10s %s(+%ld): %s\n",
+    safe_snprintf(line, LKT_MESSAGE_MAX, " %c [%02d:%02d:%02d] %-10s %s(%s+%ld): %s\n",
                   level == ERROR ? '!' : level == WARN ? '*' : level == INFO ? '.' : ' ',
                   hour, min, sec,
-                  section, func, line_number, format);
+                  section, func, file, line_number, format);
 
     va_start(ap, format);
     vfprintf(stderr, line, ap);