Skip to main content

Java CDR Logger


CDRLogger is a Java servlet application that works together with mod_xml_cdr to store CDR records into a database table. The application parses the CDR XML data and stores it into pre-configured fields. Current application 'war' packaging only includes and tests with PostgreSQL database driver. Other database driver support could be easily included (MySQL, SQL Server, Oracle, etc).

Click here to expand Table of Contents


  • Java Runtime Environment 1.5
  • Java Servlet Container (Tomcat, JBoss, Weblogic, etc)
  • Database Server: PostgreSQL ( MySQL, Oracle, SQL Server, etc)

Installation w/ Tomcat

  • Make sure JRE and Tomcat is successfully installed.
  • Download cdr-logger war package from here
  • Copy cdr-logger-x.x.war to tomcat web apps directory (replace x.x with the right version, ie. cdr-logger-1.0.war)
cp <your-download-path>/cdr-logger-x.x.war <tomcat-webapps-dir>
  • If tomcat is running, the war package should automatically expanded into its own directory

Database Connection Setup

Edit cdr-logger-x.x/WEB-INF/classes/hibernate.conf.xml under tomcat web apps. Change the database connection setup according to your database settings. For example for postgresql:

<property name="connection.url">jdbc:postgresql://localhost/mydb</property>
<property name="connection.username">postgres</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.password">yourpassword</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

Testing The Installation

Restart tomcat, under Ubuntu should be like

/etc/init.d/tomcat5.5 restart

point your browser to


It should return some error message similar to below

Unrecognized 'null' operation type. Type should be 'insert' or 'create'.

This indicate, the CDRLogger application properly installed.

Automatic Schema Generation

Now, to automatically generate database schema, point your browser to :


This will start automatic schema generation. Check your database, it should generate following database table :

CREATE TABLE freeswitch_cdrs
id bigint NOT NULL,
start_stamp character varying(32),
answer_stamp character varying(32),
end_stamp character varying(32),
profile_start_stamp character varying(32),
answered_time character varying(32),
hangup_time character varying(32),
created_time character varying(32),
billsec integer,
billmsec integer,
billusec integer,
total_duration_sec integer,
total_duration_msec integer,
sip_from_uri character varying(64),
sip_to_uri character varying(64),
sip_call_id character varying(64),
custom_tag_1 text,
custom_tag_2 text,
custom_tag_3 text,
custom_tag_4 text,
custom_tag_5 text,
custom_tag_6 text,
custom_tag_7 text,
custom_tag_8 text,
custom_tag_9 text,
xml_data text,
CONSTRAINT freeswitch_cdrs_pkey PRIMARY KEY (id)
ALTER TABLE freeswitch_cdrs OWNER TO postgres;

CREATE TABLE freeswitch_cdr_data
id bigint NOT NULL,
category character varying(64),
"name" character varying(64),
"value" text,
cdr_id bigint NOT NULL,
CONSTRAINT freeswitch_cdr_data_pkey PRIMARY KEY (id),
CONSTRAINT fkabdb2bd73aa16d74 FOREIGN KEY (cdr_id)
REFERENCES freeswitch_cdrs (id) MATCH SIMPLE
ALTER TABLE freeswitch_cdr_data OWNER TO postgres;

You can test the application to insert test record, point your browser to :


Then check freeswitch_cdrs table, it should create a sample record.

Configure mod_xml_cdr

Setup mod_xml_cdr to point to CDRLogger application.

<configuration name="xml_cdr.conf" description="XML CDR CURL logger">
<param name="url" value="http://yourip:port/cdr-logger-x.x/cdr"/>
<param name="retries" value="2"/>
<param name="delay" value="120"/>
<param name="log-dir" value="/var/log/cdr"/>
<param name="err-log-dir" value="/var/log/cdr/errors"/>
<param name="encode" value="true"/>

Make a test call and check the database table. if there is a new CDR record populated. Sit down and enjoy your coffee ;)

Additional Configuration

vi cdr-logger-x.x/WEB-INF/web.xml, there is a couple settings that you can tune. Don't forget to restart tomcat to make sure it pickup the latest changes.

  • Turn on/off raw xml storage (storeRawXML)
  • Customize xml tag storage (custom_tag_n)
  • Turn on/off automatic schema generation url (allowChemaGenerator)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="" xmlns:xsi=""
<description>Freeswitch CDR Logger\</description>
<distributable />
<!-- Log raw cdr XML -->
<!-- Log raw cdr XML -->