Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log the output from SQL print statements #22

Open
GoogleCodeExporter opened this issue Mar 27, 2015 · 4 comments
Open

Log the output from SQL print statements #22

GoogleCodeExporter opened this issue Mar 27, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Call Statement.execute() with SQL: print 'test'
2. Nothing logs.



What is the expected output? What do you see instead?

I wrote a quick Java app to test what the following SQL would output with 
Statement.getWarnings():

print 'test'

For a SQL Server 2012 database it prints:

test

For a Sybase 12.5 database it prints:

test

Please see the attached Java code.  I obfuscated the connection details, 
username and password.

I only have access to a SQL Server and Sybase database... not sure what other 
databases would output.




What version of the product are you using? On what operating system?

log4jdbc-log4j2-jdbc4.1, version 1.16 on Windows 7


Please provide any additional information below.

I am using log4jdbc-log4j2 with Liquibase so I can see more details of what 
happened during a update or rollback.  What I really want to see is the output 
of sql print statements (like the Output screen from a database tool).  I found 
that JDBC Statement.getWarnings() can be used to get SQL output:

http://dba.stackexchange.com/questions/44372/is-there-any-way-to-retrieve-messag
es-in-sql-server-through-jdbc

http://stackoverflow.com/questions/6434338/when-to-call-getwarnings-on-connectio
ns-statements-and-resultsets-with-jdbc

This feature could be activated with a system property similar to 
log4jdbc.statement.warn, defaulted to false.

Original issue reported on code.google.com by steven.d...@gmail.com on 3 Sep 2014 at 5:50

Attachments:

@GoogleCodeExporter
Copy link
Author

I had a go at implementing logging of SQL Messages and tested it in our 
Liquibase implementation with SLF4J and JDBC 4.1.  Print statements log 
successfully.

It is just a start on the full implementation. For example, I did not implement 
the Log4J 2 logging method (the method is empty) as I am not familiar with 
Log4J 2.

I also have not implemented logging of SQL Message the JDBC 3 and 4 modules.

Please see the attached Patch for Subversion.

Original comment by steven.d...@gmail.com on 4 Sep 2014 at 12:10

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks for the proposed patch. Question: if you plan to use a specific logger 
for these messages, why defining the property DumpSqlMessage? This could be 
managed simply by setting the appropriate logger on/off, right?

Original comment by frederic...@gmail.com on 7 Oct 2014 at 4:12

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Actually, I see that SQLWarnings should be logged by the 'resultSetLogger' when 
using SLF4J, and with the Marker 'LOG4JDBC_RESULTSET' when using Log4j2. Have 
you tried using these loggers/markers?

Original comment by frederic...@gmail.com on 31 Jan 2015 at 11:21

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Original comment by frederic...@gmail.com on 31 Jan 2015 at 11:21

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant