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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
---
title: Server Logs & System Info
url: /instance-administration/system-info/
---
The System Info page is found at **[Administration > System](/#sonarqube-admin#/admin/system)**. It gives you access to detailed information on the state of your SonarQube instance.
## System Info
You can browse details about your running instance on this page.
### Download
Additionally, if you have a Support contract, you might be asked by a Support representative to send in your System Info, which can be downloaded from the page **[Administration > System](/#sonarqube-admin#/admin/system)** using the **"Download System Info"** button at the top.
### Server Id
Your server id can be obtained from this page by expanding the **System** section. If you're running a commercial instance, you can also find this value on the License page (**[Administration > Configuration > License Manager](/#sonarqube-admin#/admin/extension/license/app)**)
## Logs
Server-side logging is controlled by properties set in _$SONARQUBE-HOME/conf/sonar.properties_.
4 logs files are created: one per SonarQube process.
### Log Level
The server-side log level can be customized via the `sonar.log.level` property. Supported values are:
* **`INFO`** - the default
* **`DEBUG`** - for advanced logs.
* **`TRACE`** - show advanced logs and all SQL and Elasticsearch requests. `TRACE` level logging slows down the server environment, and should be used only for tracking web request performance problems.
### Log Level by Process
The server-side log level can be adjusted more precisely for the 4 processes of SonarQube Server via the following property:
* **`sonar.log.level.app`** - for the Main process of SonarQube (aka WrapperSimpleApp, the bootstrapper process starting the 3 others)
* **`sonar.log.level.web`** - for the WebServer
* **`sonar.log.level.ce`** - for the ComputeEngineServer
* **`sonar.log.level.es`** - for the SearchServer
### Log Rotation
To control log rolling, use the `sonar.log.rollingPolicy`
* **`time:[value]`** - for time-based rotation. For example, use `time:yyyy-MM-dd` for daily rotation, and * `time:yyyy-MM` for monthly rotation.
* **`size:[value]`** - for size-based rotation. For example, `size:10MB`.
* **`none`** - for no rotation. Typically this would be used when logs are handled by an external system like logrotate.
`sonar.log.maxFiles` is the maximum number of files to keep. This property is ignored if `sonar.log.rollingPolicy=none`.
### UI Access to Logs and Log Levels
The System Info page gives you the ability to download your instance's current log files (log files rotate on a regular basis), and to tune the log level via controls at the top of the page. Changes made here are temporary, and last only until the next time the instance is restarted, at which point the level will be reset to the more permanent value set in _$SONARQUBE-HOME/conf/sonar.properties_. Regardless, if you change your log level _from_ `INFO`, but sure to change it back as soon as is practical; log files can get very large very quickly at lower log levels.
## Total Lines of Code
### SonarQube 6.7 LTS and newer
The number of Lines of Code (for licensing purposes) in an instance can be found in the **System** section of the System Info page on, and on the License page (**[Administration > Configuration > License Manager](/#sonarqube-admin#/admin/extension/license/app)** in commercial editions.
If you're on a commercial edition and using Branch or PR analysis, rest assured that only lines from the single largest branch in a project are considered for licensing purposes. The Lines of Code in the rest of the branches are ignored.
### Versions older than 6.7
The best approach there is to query the database. The actual query varies based on the version of SonarQube and the database engine. Two queries are provided:
* one query that counts LOCs across *all* projects
& one query that filters out project branches (i.e. projects analysed with the `sonar.branch` parameter). However, this query is accurate only if projects with branches are also analysed once without sonar.branch.
**SonarQube LTS v5.6.x**
[[collapse]]
| ## MySQL
|
|**Note** – Starting with version 7.9, SonarQube will no longer support MySQL. To migrate from MySQL to a supported database, see the [MySQL Migrator tool](https://github.com/SonarSource/mysql-migrator).
|
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
|```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc'
| and (
| INSTR(p.kee, ':') = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTR(p.kee, 1, LENGTH(p.kee) - INSTR(REVERSE(p.kee), ':'))
| ));
|```
[[collapse]]
| ## PostgreSQL 8.0-9.0
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| Not feasible on this specific database
[[collapse]]
| ## PostgreSQL 9.1+
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc'
| and (
| POSITION(':' IN p.kee) = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTRING(p.kee, 0, LENGTH(p.kee) - POSITION(':' in REVERSE(p.kee)) + 1)
| ));
| ```
[[collapse]]
| ## Oracle
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc'
| and (
| INSTR(p.kee, ':') = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTR(p.kee, 0, INSTR(p.kee, ':', -1) - 1)
| ));
| ```
[[collapse]]
| ## Microsoft SQL Server (a.k.a MSSQL)
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.project_id = p.id
| inner join project_measures pm on pm.snapshot_id = s.id
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_resource_id is null
| and pm.person_id is null
| and m.name='ncloc'
| and (
| CHARINDEX(':', p.kee) = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTRING(p.kee, 0, LEN(p.kee) - CHARINDEX(':', REVERSE(p.kee)) + 1 )
| ));
| ```
**SonarQube 6.0-6.6**
[[collapse]]
| ## MySQL
|
|**Note** – Starting with version 7.9, SonarQube will no longer support MySQL. To migrate from MySQL to a supported database, see the [MySQL Migrator tool](https://github.com/SonarSource/mysql-migrator).
|
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc'
| and (
| INSTR(p.kee, ':') = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTR(p.kee, 1, LENGTH(p.kee) - INSTR(REVERSE(p.kee), ':'))
| ));
| ```
[[collapse]]
| ## PostgreSQL 8.0-9.0
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| Not feasible on this specific database
[[collapse]]
| ## PostgreSQL 9.1+
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = true
| and p.enabled = true
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc' and (
| POSITION(':' IN p.kee) = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTRING(p.kee, 0, LENGTH(p.kee) - POSITION(':' in REVERSE(p.kee)) + 1)
| ));
| ```
[[collapse]]
| ## Oracle
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc'
| and (
| INSTR(p.kee, ':') = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTR(p.kee, 0, INSTR(p.kee, ':', -1) - 1)
| ));
| ```
[[collapse]]
| ## Microsoft SQL Server (a.k.a. MSSQL)
| Global LOCs
| ```
| select sum(pm.value) as global_loc from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc';
| ```
| LOCs without `sonar.branch`
| ```
| select sum(pm.value) as loc_without_branch from projects p
| inner join snapshots s on s.component_uuid = p.uuid
| inner join project_measures pm on pm.analysis_uuid = s.uuid
| inner join metrics m on m.id=pm.metric_id
| where s.islast = 1
| and p.enabled = 1
| and p.qualifier = 'TRK'
| and p.scope = 'PRJ'
| and p.copy_component_uuid is null
| and pm.component_uuid = p.uuid
| and pm.person_id is null
| and m.name='ncloc'
| and (
| CHARINDEX(':', p.kee) = 0 or not exists(
| select * from projects p_root where p_root.kee = SUBSTRING(p.kee, 0, LEN(p.kee) - CHARINDEX(':', REVERSE(p.kee)) + 1 )
| ));
| ```
|