--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ PG_CFLAGS = -Wall -Wdiscarded-qualifiers
 
 MODULE_big = pgauditlogtofile
 OBJS = pgauditlogtofile.o logtofile.o logtofile_bgw.o logtofile_connect.o logtofile_guc.o logtofile_log.o logtofile_shmem.o logtofile_autoclose.o logtofile_vars.o logtofile_filename.o
+REGRESS = logtofile
 
 EXTENSION = pgauditlogtofile
 DATA = pgauditlogtofile--1.0.sql pgauditlogtofile--1.0--1.2.sql pgauditlogtofile--1.2--1.3.sql pgauditlogtofile--1.3--1.4.sql pgauditlogtofile--1.4--1.5.sql pgauditlogtofile--1.5--1.6.sql
--- /dev/null
+++ b/expected/logtofile.out
@@ -0,0 +1,11 @@
+-- truncate log file before test
+create table foo (t text);
+copy foo from program 'sh -c "> /tmp/pgauditlogtofile"';
+select 1\g
+ ?column? 
+----------
+        1
+(1 row)
+
+\! grep -o 'SESSION.*' /tmp/pgauditlogtofile
+SESSION,3,1,READ,SELECT,,,select 1,<not logged>,,,,,,,,,pg_regress/logtofile
--- /dev/null
+++ b/sql/logtofile.sql
@@ -0,0 +1,7 @@
+-- truncate log file before test
+create table foo (t text);
+copy foo from program 'sh -c "> /tmp/pgauditlogtofile"';
+
+select 1\g
+
+\! grep -o 'SESSION.*' /tmp/pgauditlogtofile
