Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
tests
testPropConfig.cpp
Go to the documentation of this file.
1
// testConfig.cpp : Derived from testPattern.cpp.
2
//
3
4
#include <
log4cpp/Portability.hh
>
5
6
#ifdef WIN32
7
#include <windows.h>
8
#endif
9
#ifdef LOG4CPP_HAVE_UNISTD_H
10
#include <unistd.h>
11
#endif
12
13
#include <iostream>
14
15
#include <
log4cpp/Category.hh
>
16
#include <
log4cpp/PropertyConfigurator.hh
>
17
18
int
main
(
int
argc,
char
* argv[])
19
{
20
try
{
21
std::string initFileName;
22
#if defined(WIN32)
23
initFileName =
"./log4cpp.nt.property"
;
24
#else
25
initFileName =
"./log4cpp.property"
;
26
#endif
27
log4cpp::PropertyConfigurator::configure
(initFileName);
28
}
catch
(
log4cpp::ConfigureFailure
& f) {
29
std::cout <<
"Configure Problem "
<< f.what() << std::endl;
30
return
-1;
31
}
32
33
log4cpp::Category
& root =
log4cpp::Category::getRoot
();
34
35
log4cpp::Category
& sub1 =
36
log4cpp::Category::getInstance
(std::string(
"sub1"
));
37
38
log4cpp::Category
& sub2 =
39
log4cpp::Category::getInstance
(std::string(
"sub1.sub2"
));
40
41
root.
error
(
"root error"
);
42
root.
warn
(
"root warn"
);
43
sub1.
error
(
"sub1 error"
);
44
sub1.
warn
(
"sub1 warn"
);
45
// the following 2 should only be in A1, not A2
46
sub1.
info
(
"sub1 info"
);
47
sub1.
debug
(
"sub1 debug"
);
48
49
// do a few so that the log rolls over
50
sub2.
warn
(
"sub2 warn 1"
);
51
sub2.
warn
(
"sub2 warn 2"
);
52
sub2.
warn
(
"sub2 warn 3"
);
53
sub2.
warn
(
"sub2 warn 4"
);
54
sub2.
warn
(
"sub2 warn 5"
);
55
sub2.
warn
(
"sub2 warn 6"
);
56
sub2.
warn
(
"sub2 warn 7"
);
57
58
#if defined(WIN32)
59
log4cpp::Category
& nt =
60
log4cpp::Category::getInstance
(std::string(
"subNT"
));
61
nt.
error
(
"subNT error"
);
62
nt.
warn
(
"subNT warn"
);
63
nt.
debug
(
"subNT debug"
);
64
#endif
65
66
log4cpp::Category::shutdown
();
67
68
return
0;
69
}
70
PropertyConfigurator.hh
log4cpp::Category::debug
void debug(const char *stringFormat,...)
Definition:
Category.cpp:291
log4cpp::Category
Definition:
Category.hh:33
log4cpp::Category::warn
void warn(const char *stringFormat,...)
Definition:
Category.cpp:333
log4cpp::Category::getInstance
static Category & getInstance(const std::string &name)
Definition:
Category.cpp:35
log4cpp::Category::shutdown
static void shutdown()
Definition:
Category.cpp:48
log4cpp::ConfigureFailure
Definition:
Configurator.hh:21
Portability.hh
main
int main(int argc, char *argv[])
Definition:
testPropConfig.cpp:18
log4cpp::Category::getRoot
static Category & getRoot()
Definition:
Category.cpp:23
Category.hh
log4cpp::Category::info
void info(const char *stringFormat,...)
Definition:
Category.cpp:305
log4cpp::Category::error
void error(const char *stringFormat,...)
Definition:
Category.cpp:347
log4cpp::PropertyConfigurator::configure
static void configure(const std::string &initFileName)
Definition:
PropertyConfigurator.cpp:14
log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:14:17