본문 바로가기
Developer/DB

[DB] log4j설정 포스트그레 20220906

by 순수한소년 2021. 5. 10.
728x90
반응형

 

globals.properties

1
2
3
4
Globals.DriverClassName=net.sf.log4jdbc.DriverSpy
Globals.Url=jdbc:log4jdbc:postgresql://123.123.123.123:5433/test
Globals.UserName =postgres
Globals.Password =postgres
cs

log4jdbc-log4j2-jdbc4-1.16.jar파일을 사용할 때는

Globals.DriverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy

 

context-datasource.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">    
 
    <bean id="egov.propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/egovframework/egovProps/globals.properties</value>
            </list>
        </property>
    </bean>
 
    <!-- DataSource -->
    <alias name="dataSource" alias="egov.dataSource"/>
    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${Globals.DriverClassName}"/>
        <property name="url" value="${Globals.Url}" />
        <property name="username" value="${Globals.UserName}"/>
        <property name="password" value="${Globals.Password}"/>
    </bean>    
    
    <!-- Transaction -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    
    <tx:annotation-driven transaction-manager="transactionManager"/>
    
</beans>
 
cs

log4j는 생략

log4sql.jar
0.08MB

 

728x90
반응형